I have several tables: product
, category
, addon
in various relational relationships.
I structured it this way because: I have many products
that belong to their own specific category
. For each category there are specific addons
.
Price Table
What I want to do is to add a pricing table that I will be able to query to find out things like
- (main) How much does product addon cost for this specific product.
- (optional) what is the current price for the product. That is, I can have several prices in the table that belong to the same
product-addon
, but have different timespans (dates) of being "active".
This is the structure I am thinking of using (updated as per comments/suggestions):
Is that a good way to structure the table? I would call this "Option 1", where "Option 2" would be to create a new table called product_addon
as glue between product
and addon
and then use foreign key product_addon_id
in my price
table.
Best Answer
Option 1 (because it is the most simple one), but I suggest you call the link table between products and addons not "price", better call it "product_addon".
Option 2 is only necessary if you need a list of prices for the same addon in a product (whatever that would mean).