GroundApps / ShoppingList_Backend

Simple Centralized Shoppinglist - php backend
GNU General Public License v3.0
27 stars 23 forks source link

Unified database layout. #47

Closed jklmnn closed 8 years ago

jklmnn commented 9 years ago

While trying to create a pdo abstraction (see #38 ) I noticed that the MySQL and the SQLite databases have different table layouts. That makes it difficult to create an abstraction and would cause much more code that could be avoided. I would suggest using a unified table layout. I would use:
STRING item PRIMARY INDEX NOT NULL; INT count NOT NULL; BOOL checked NOT NULL;

J-8 commented 9 years ago

Good idea. What could be useful for future ideas would be Timestamp User Category or list to have multiple lists isImportant

jklmnn commented 9 years ago

I would not put the user as database entry. I'd rather would create a table for each user. I don't think that we should consider users at all since we don't have any user management at all currently. Category can be easily added as column. But it should be able to be NULL what would be uncategorized then. It would be interesting if the timestamp functionality is already provided by databases. what would be isImportant for?

<slightly offtopic> I have seen that you have checked/unchecked functionality in your app but I didn't find any functionality for that in the backend in version 1.0. Is this only local? </slighly offtopic>

J-8 commented 9 years ago

The user thing was meant more like a small colored dot in the bottom left corner which indicates which user added what to the list. I would not implement a real user management. I think that is not within scope. The isImportant is the question.... should there be a category "Important" among all other categories OR should it be possible to mark individual items of a category as important?

The checked/unchecked is the bool that marks if an item has been marked as done (when it is striked through). It is only local.
jklmnn commented 9 years ago

I think the checked thing is something that should also be synced.

Well, but if you add something as a specific user, we either need a set of allowed users. Otherwise it would just be a category.

I would stay with one category and one checked field at the moment.

J-8 commented 9 years ago

The idea was that you just get assigned a random color which in the list indicates who added what. Completely unrelated to categories. I just thought it would be nice eye candy ;) Not really important right now...

So you would make "important" a category?

jklmnn commented 9 years ago

Yep, I think that's dedicated enough.

J-8 commented 9 years ago

Good for me, less work ;)

jklmnn commented 9 years ago

I recall: STRING item PRIMARY INDEX NOT NULL; INT count NOT NULL; BOOL checked NOT NULL; STRING category;

Will you change the api functions accordingly? I'll adapt the db connector then.

J-8 commented 9 years ago

I'll add some functions for the new usages. The listall should then give back a json array of items like this: {'itemTitle': Title of item, 'itemCount' => Count of item, 'checked' => false, 'done' => false, 'itemCategory' => Category of item} I am not sure if the 'done' part is necessary, I had to include it to be able to convert it to the used java object. I have to check gson and give you an update.

jklmnn commented 9 years ago

I think done and checked are the same thing.

J-8 commented 9 years ago

Yeah, you're right... I am being stupid again.

jklmnn commented 9 years ago

Ok, I'll implement STRING item PRIMARY INDEX NOT NULL; INT count NOT NULL; BOOL checked NOT NULL; STRING category; for the new database connector. I don't think updating the old ones makes sense since this one is replacing them.

jklmnn commented 9 years ago

I have completed the pdo db connector, so I will close this.