Among the many ways of approaching this, I'd highlight these:
- Have a separate
Product
record for every colour/size combination of every item. Each has its own price.
- If many items will share similar sizes and colours (if you're selling shirts, for example, and every shirt is available in any of five sizes and three colours), it may make sense to normalize
Size
and Colour
into their own tables, and have a PricePoint
table that stitches them all together - every combination of item, colour, and size has an entry in PricePoint
with the appropriate price.
Note that the second approach, while more-normalized, could cause issues in product / inventory tracking. Since it's easier to track individual items if each item at each price point has its own SKU (or other common identifier), you may prefer a mixed approach:
- A
Product
table that will contain a record for every combination of item, size, and colour, with a unique SKU and Price for each.
- A
Size
table that normalizes out the common sizes your Products may have. Product
has a foreign key to this table.
- A
Colour
table, as above.
- A
ProductType
or ProductGrouping
table that defines supersets of products for ease of organization / search. Each Product will have a foreign key to this "parent product" table. For example, you might have a ProductType = 'T-Shirt' that has several dozen Products associated with it - one Product for each combination of shirt style, size, and colour.
Update: To elaborate on the "superset" table, per the OP's request, I would extend @Phil Sandler's example this way:
Add a Product Group table:
Product Group (defines a superset of similar products that will be grouped or filtered together)
product_group_id
product_group_name
And edit the Product table to add a foreign key to Product Group:
Product Table (defines the product):
product_id
product_group_id
product_name
Now, to highlight an example combination at a particular price point, some made-up data:
Product: product_id=100, product_group_id=1, product_name='Men's Crew-neck T-shirt'
Product Group: product_group_id=1, product_group_name='T-Shirts'
Color: product_color_id=10, product_id=100, color_id=6 Assume '6' is 'Blue'. This record means the Crew-neck T is available in Blue
Size: product_size_id=11, product_id=100, size_id=2 Assume '2' is 'Medium'. This record means the Crew-neck T is available in Medium
Price: product_price_id=555, product_id=100, product_size_id=11, product_color_id=10, price=24.99
*This record means the Medium Blue Crew-neck T is priced at $24.99 (note the price_id, which was missing from Phil's example)*
The Product Group table would, using this example, let you do queries across a product line, such as "Select the most-expensive Large T-Shirt that we sell."