Let us say that, in my business context, there are three different products, i.e., product one, two and three, and I wish to offer price discounts when a condition like the following one takes place:

  • If a customer buys 2 units of product one and 1 unit of product two, I will give him a price discount of x% on product three.


How should I model the situation described above in my database structure?

  • 2
    Do the business logic in your application code, not the database. A database is for storage of data and only simple 'models'. – Rick James Sep 5 '16 at 23:47
  • @RickJames, I agree that the business logic should be handled in the application but there is still a need to store the business rules for the discounts. I think that's what the OP was asking. – Shooter McGavin May 16 '18 at 14:33
  • That particular discount seems rather complex -- since it involves 3 products. Can you list the rules with pencil and paper in tabular format? If so, then you have the contents of the necessary table. – Rick James May 16 '18 at 15:39
  • Is it always one, two, and three? Or maybe other products? Is it always buy 2 (not 1, not 6) different things to get a discount on exactly 1 other product? (I suspect that the specification is incomplete, so I don't want to guess at an answer.) – Rick James May 16 '18 at 15:41
  • I have solved this by creating a table for the disscount and two extra tables one for indicator products and one for objective products, additionally if the disscount is for a set of exclusive clients i created another table for clients that can make use of the disscount. – Juan Manuel Rodriguez A. May 17 '18 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.