I have products in my database (MySQL).
I have my prices based on different combinations of options for my products.
I have the following data:
PRODUCTS
prodID | prodName
1 | Ball
OPTIONS
optionID | optionName | prodID
1 | color | 1
2 | size | 1
3 | material | 1
OPTIONVALUES
ovID | optionID | ovValue
1 | 1 | red
2 | 1 | blue
3 | 2 | small
4 | 2 | big
5 | 3 | wood
6 | 3 | glass
for prices I would like to have like this:
red small wood ball – $13
red small glass ball – 14
red big wood ball – 16
red big glass ball – 17
blue small wood ball – 12.5
[…]
How can I design the database structure for this?
I have tried several ways but none was good. if the number of the options were static then every option could have its own table, but this was that is not a good solution.
I like what you already have. If you want it to be fully flexible as i guess you do, i would do the following:
Add two more Tables.
Product_Instance
Product_Instance_Options
In this way you could define all possible combinations and prices for them. Might be a hell of a lot work to set up all the prices, but if you cant calculate them (like glass = +2$, small=2$ / big=4$) you will have this however you do it.