Data Model for Combination Discount

I need to design data model for combo discount
I have the following scenario for -
item1 + item2 => 10% discount
item1 + item3 => 12% discount
item2 + item4 => 11% discount and so on…

The number of items in combination could be variable. eg:
item1 + item2 + item3 + item4 => 15%discount

Can someone provide guidance about how to approach this problem using mongodb?

From the examples you provided, it looks like there is no logic on how you change the discount. It looks like it is completely arbitrary to which items are combined.

What happen when you have item1, item2 and item3? Is it 10% because i1 and i2 is there? Or is it 12% because i1 and i3 is there? It cannot really be 10% because I would not have any incentive of having i3 also. If 12%, then i2 does not increase my discount, now I am disappointed, I will buy i2 else where.

You need to develop a better and predictable way to compute your discount, otherwise you will end up with a big spaghetti of if-then-else.


  1. 2 items and more gives 10%
  2. Any extra item above 2 items gives an extra 1%


I think the most straightforward approach would be to compute your combo discounts in application logic and save the calculated discount value (and perhaps a discount_reason) in your data model. As @steevej mentioned, the logic for the discount calculation will also need a clearer calculation as the expected outcome isn’t obvious from the current information.

If you are dealing with values that need fractional precision (for example, a calculated currency amount) you should also use the Decimal128 BSON type for those values.