chain supermarket inventory ERD

syn3rgyz

Gawd
Joined
Jun 14, 2005
Messages
763
I'm trying to create an ERD for a supermarket chain and I got stuck after creating the products and store table. under products I have ProdID as the primary key and under store I have storeID as the primary key. My problem is how would I differentiate the different products at each store? If I added an inventory table what would be the primary key for that?
 
You need another table to link the other two tables together, also you may want to include some additional attributes in the column such as price (I guarantee there will be variations from store to store) and stock level.

Plus there is the multiple levels/ type of discounts - have fun!
 
I was going to link the two tables together with the inventory table which has both storeid and productid, but then none of them would be unique to be used as a primary key for the inventory table, isnt that a problem?
 
Then you have solved it already.

No it isn't a problem as long as you have unique indexes in a given table. This can be by using a surrogate key (unique but doesn't really mean anything) or use compound keys which are a combination of other (typically foreign) keys.
 
Back
Top