Click to See Complete Forum and Search --> : Relational Database Design: Modelling product variants in an e-commerce application


DodgerLD
February 8th, 2005, 02:51 PM
Hi,

I'm working on the database design for an e-commerce application, and I'm finding it difficult to
model the following situation:

Each product may have 0 or more options, such as size and color, and each option may have 1 or more
values, eg: Color: Red, White, Blue; Size: 5, 10, 15, 20, etc.

Two separate products might have the same option/s, for example color, but with a different set of
choices. eg: Nike Shirt (Colors: Red, Green, White) and Addidas Shorts (Colors: Blue, Green, Black)

I would prefer the design to be in 3rd normal form, so something like this wouldn't really be optimal:

=========================================================================
product_details: | id | name | price |
=========================================================================
| 0001 | ABC Shirt | 26.00 |

=========================================================================
product_options: | product_id | option_name | option_values |
=========================================================================
| 0001 | Color | Red, White |
| 0001 | Size | 5, 10, 15 |

More importantly, price may differ according to the size and color of the product.
Not to mention the fact that each variant may have a different quantity in stock at any given time.

So, essentially, a price and quantity has to be maintained for each product variant.

Any ideas?

TIA.