What’s the best database design for the following problem:
I have a product with several attributes like color, size, material. Depending on these attributes I want to calculate the total price of a product. Every attribute can hold a specific price. So the price of the product is the sum of all its attribute’s costs.
First idea would be 3 tables
A SUM on ProductAttribute per Product would give the price
If you have a fixed and finite set of attributes, then these could be separate columns in a single product table with a computed column to add them up. However, my feeling is that you have a variable number of attributes for each product. So factor then out into a separate table.
Try not to stray into EAV territory of course… 🙂
Edit: after question update
I’d use Object Role Modelling to capture the model before I think about implementing.
The fact or size per colour changes the design considerably