I am building an e-commerce website from scratch and have to make a special product configuration page.
It’s only 1 type of product, but it is configurable on several levels:
- Color (about 4 different options). Value is a VARCHAR.
- Material (about 10 different options). Value is a VARCHAR.
- Size (About 30 different options). Has 2 Values, a width column and a height column.
- Finish (About 20 different options). Value is a VARCHAR.
- Other various VARCHAR options etc.
My question is what would this look like in a typical MySQL database. Do I have a table for each type of option or just one table and somehow give it enough columns and have it store all options? I will need to store orders and be able to store the information for the order in a table as well.
I also want to be able to have off the shelf products that aren’t customizeable, just like a normal store.
Any help is appreciated!!
I suggest that you go with one master table, with all of the product information, and a slew of lookup tables, that connects to the master table.
It should look like this:
And here’s the lookup table:
The
Product_tablecan look like this:Whereas the
lkp_color_tablecan look like this:Note that
lkp_color_tablecan contain unusedcolor, same goes for other lookup tables. So if you have 30 possible colors, you just have to populatelkp_color_tablewith 30 items, and so on.There is no need to create a separate
Product_idfor each color-material- combination, you just have to create aproduct_idif you use it.