bytefury's avatar

Ecommerce Product Variants

I am confused about how to implement Variants for each product. Also note that each variant has its own price.

Size - Small - Price - 200 , Size - Medium - Price - 400

what would be the best way to save this on database?

currently i am thinking about creating one to many relationship of product > Variants.

Variants Table Schema : ID , product_id , size & price

Open to suggestions

0 likes
3 replies
frezno's avatar

no, that's not the right way. Not a variant owns products but the product does.

You have to have multiple tables:

  • products
  • variants
  • product_variant
  • prices
That way you can handle everything and are flexible on the requirements

Please or to participate in this conversation.