DEV Community

Discussion on: what is an optimized way of product discount in DB?

Collapse
bjkippax profile image
Ben • Edited

The way my team works is to have separation.

Tables.

  1. Product
  2. Attributes (S,M,L etc all with prices for the individual attribute) FK product uid
  3. AttributeDiscounts (type (enum Fixed, percentage etc), value int) FK to attribute uid
  4. ProductDiscounts (type (enum Fixed, percentage etc), value int) FK to product uid

Attribute Discounts override Product Discounts.

If you apply this principal to your data, you would need to extend AttributeDiscounts/ProductDiscounts to accept a min & max items for your bulk discounts.

Collapse
iamshareque profile image
Shareque Author

thanks, Ben I will try this

Collapse
bjkippax profile image
Ben

No worries. Any issues, reply here and I can provide some further guidance. I have notifications turned on.