I have a problem in designing a database for a "business". I have some database for different types of products( for example car parts, groceries and some other stuff). Now if I want to make a business, meaning that I want to sell these items, I am thinking that I am going to need a table like Products which will contain a product foreign key, a stock and a price. My question is how can I use foreign keys in my Products table from my existing tables? I was thinking of using a combination of foreign keys (i.e in the Products table I would have a column for each product type), but I don't think it's such a good idea. What if I would want to expand my business to other types of products? Any ideas?
Asked
Active
Viewed 145 times
0
-
Take a look at this previous answer on inheritance: http://stackoverflow.com/questions/190296/how-do-you-effectively-model-inheritance-in-a-database – Marcus Adams Mar 08 '12 at 18:46
1 Answers
-1
Consider inheritance:
You can use a table products which will be supertype of the products you have and refer to this table though the foreign key. If you want more info about how to implement inheritance click here

Community
- 1
- 1

Mario Corchero
- 5,257
- 5
- 33
- 59