3 ms·
(I'm making an educated guess about the author's intent.) I think the author wanted to keep the example brief and omitted several columns from the todo_lists t
by ozgune 9y ago
(I'm making an educated guess about the author's intent.)
I think the author wanted to keep the example brief and omitted several columns from the todo_lists table. In practice, you may have a creation time, last edit time, share options, and other fields for each list -- the todo_lists table.
You wouldn't want to duplicate these values in the todo_items table. By having a user_id on both tables, you can query the todo_lists table on user_id, and join the two tables if needed.
On the "if users have the same list id ..." question, I don't think they need to. If you're for example using UUID or sequence ids, then they wouldn't clash. If the application however had its own logic to generate list ids, then they might.
Again, these are just my educated guesses on the author's intent. Hopefully, they answer your questions.