I'd like to design something that would allow users to put lists together of, let's say, grocery items. If each user can have multiple lists (ie not a set amount) and those lists all have a variable number of items on them (again, not set) while some items appear on several different lists , how do I create a database without being horribly redundant?
I'm completely new to this kind of problem, not having put together any complex database before, and have no idea where to start. This is what I came up with as an example, but I doubt this is the right way of doing things:
Any help or ideas would be much appreciated!
You can create join table LIST_LINK_ITEM
between three tables
Her primary key is : composition of three primary keys
Looks like you need something similar to this:
A list is private to user, but an item can be shared among multiple lists:
I have used identifying relationship between USER and LIST in the diagram above, producing more "natural" keys in the "downstream" tables which:
The design using non-identifying relationship between USER and LIST (producing "slimmer" keys) would look like this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.