r/DatabaseHelp • u/qetuop1 • Apr 02 '16
Many-to-many, reference, table linking, mapping, filtering, composite keys, ???
Not exactly sure what words to describe my question as I'm a novice when it comes to databases.
I am trying to make a simple grocery list app using sqlite. At this point I want to display a list of Items and the Aisle they are in for a given Store.
I'm thinking I need a Item table(id, name), a Store table(id, name) and possibly an Aisle number table(id,aisle)? With extra mapping tables between them all?
EX:
Item(Milk) --> Store(Wegmans) --> Aisle(2)
Item(Milk) --> Store(Safeway) --> Aisle(15)
2
Upvotes
View all comments
Show parent comment
2
u/phunkygeeza Apr 03 '16
One more quick thing. It might help....
Your Associative entity can be quite powerful. Simply adding a datetime stamp can turn it into an Event table.
In your 'empty' store setup, you might think of these entries as 'stocking' events, recording when and how much stock was put in the aisle. This is also another reason you want the Aisle entity, so you can model your stores, then 'fill' them.
From that you almost have a functional stock tracking system... if you can feed it the data.