Search code examples
phpmysqlbusiness-logic

System of offers with multiple offers and products


I am developing a system of offers and I came up with the following problem:

If I have an offer that buying the "product A" and "Product B" I paid 10% less, I can register as a new offer such a product like Coke, putting the price discounting 10%, ok, but the problem is, if the user select the product A and product B I want to convert it to a discount, ie, selecting the products that generate the discount, the user takes the discount.

My solution is: I could make a table with the products and set the type of product as normal and promotion, if the type of product is promotion, will have a table associated with the products (in this case the product A and product B), but If I have 10 offers, I need to verify each product to ensure it participates in the promotion, I think soo slow.

Sorry my English, if you don't understand me, leave a comment. thanks!


Solution

  • Setup the products table as normal. Then set up a special offers table and a table for the products included in each offer.

    Products Table

    product_id

    product_name

    Offers Table:

    offer_id

    percent_off

    Products_In_Offer Table

    offer_id

    product_id