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.
In general, an attribute is a characteristic. In a database management system (DBMS), an attribute refers to a database component, such as a table. It also may refer to a database field. Attributes describe the instances in the column of a database.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With