I am trying to find out the best way to structure data in collections and items in Kinvey database.
as I am completely new I would like to get advice.
Let say I have a simple todo app.
-every user can have a lot of todo lists.
-every lists have unique id.
-lists can by private or public (everyone can see them).
-every todo-list consists of fairly simple todo-items objects
my question is
What would be better data structure?
either every unique list saved as a collection (may result in many collections created dependent on users)
one collection which has all todo-item objects saved in it (with list unique ID a s param) and query them by lists UUID
and is it worth of creating separate collections for active and completed objects ? or just add Boolean parameter to todo-item indicating either if it is completed or active
What would be the most efficient and proper way of tackling this task
I hope it all make sense.
many many thanks
almost 6 years ago
I think that in general, you need to decide how you're going to structure things like this before you implement anything. While I'm capable of giving some advice on how to generally structure your data (a boolean flag for finished is going to generally be easier than having 2 tables, especially if you do a lot of searching of "all" items (with joins)).
So in general, what I'd recommend is:
1-to-many relationship from users -> lists.
1-to-many relationship of list -> items
Each item contains a certain number of fields (name, complete, public?, etc.)
Using this type of format makes collections easy to keep straight in your head. Everything is in 1 place, easy to code around, and fairly easy to index (in your head)
As for your question about efficiency, it really depends on what you mean by efficient. Whatever allows you to program faster will likely be the more "efficient" option unless you get a tremendous amount of data flowing through your program.
If you are looking for a more specific answer with regards to your application, you can feel free to message me and I'll give you some more input.