php - multiple attribute database design -


i have product has many color variants , need design database tables. it's same product not models have same color variants. 1 product has 3 color , other may have 6 colors.

here going. can have price field in both, models , options sum in script, way can have different price depending on model , color option.

enter image description here

update

your query somoething like:

select p.name 'product', m.name 'model', m.description 'model_description', o.name 'option' `products` p  left join `models` m on (p.id = m.product_id)  left join `option_to_model` otm on (m.id = otm.model_id)  left join `options` o on (otm.option_id = o.id) 

here live example sqlfiddle


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -