Reputation: 619
I'm new in relation Database and I try to a design relation between tables but unable to figure out something.
I'm trying to design a supermarkets application which should save information about every supermarket in my system (I could have more than one super market from some type).
I have these relations in mind:
but I need help to find the relation between the supermarkets and prices or how to get information about price about some product in specific supermarket.
Upvotes: 0
Views: 355
Reputation: 5141
Your design should be in a below way
super_market table --------> Product table
Product table --------> Price table
Explinations,
Super_market
Product(reference primary key of Super_market)
Price(reference primary key of Product
Go through below link and understand the right approach for your design. https://www.computerweekly.com/tip/Inmon-or-Kimball-Which-approach-is-suitable-for-your-data-warehouse
Upvotes: 1
Reputation: 431
You should make at least 4 tables:
This is the right way to normalize tables (despite we have table Prices with composite primary key including 2 columns). So, the relations will be:
Upvotes: 0
Reputation: 111
Supermarket - supermarket(primary key), Location
Product - product_id(primary key), description
Price - supermarket(primary key), product_id(primary key), price
Instead of the relations shown in the your diagram, the relations have to be,
Upvotes: 0