I’m wondering if anyone could help with the following issue, as it turns out my issue is more complicated than I originally thought.
Basically, I have come up with a small database design to allow me to store product attributes, with price changes/stock level. So I could store an attribute for a product that adds £10 to the price and has 10 stock. See below:
However, what I’m having more of an issue with is storing combinations of attributes for stock levels. I’ve tried a few links tables, but everything seems to get very messyt pretty quickly. Is my original design (above)?
Here is a design you can try instead. It is rather complex but provides the ability to specify distinct pricing per physical item without being to repetitive.
products(think of this as a abstract bucket that groups physical products ie. part numbers).
id
title
product_part_numbers
id
products_id (product physical item belongs to)
sale_price
msrp
stock
product_attributes
id
products_id (product attribute corresponds to)
attribute (name of attribute for products such as; color, size, weight, etc)
weight (ordering when product has more then a single attribute)
product_attribute_values
id
product_attributes_id (attribute value corresponds)
attribute_value (value of attribute for color ie. red, blue, yellow, etc)
product_part_numbers_to_attribute_values
product_part_numbers_id (physical item)
product_attribute_values_id (attribute value)
Distinct pricing, stock info and attribute value combinations can now be specified per physical item (part_number).