Sidart's avatar
Level 12

E-commerce Product Option Database Structure

so i been developing an e-commerce website and i been thinking about how to handle product option like color and size, so my approach is this!

Table Structure

Products Option Table ===> product_id / p_option_price / p_option_stock

Option Table ===> id / type(color-size)

Option Value Table ==> option_id / name(red,small,large) / image

Option Product Pivot table ==> product_id / option_value_id

Relationships

A product hasMany ProductOption

ProductOption hasMany OptionValues and OptionValues hasMany ProductOptions with Pivot table option products

Option hasMany OptionValues

My only issue is that the option value table will have a lot of duplicate value cause i will be adding each products values name and image into that table!

Is this a good structure for future flexibility?

0 likes
2 replies

Please or to participate in this conversation.