I am building an ecommerce site and would like to offer discounts on certain items for a limited time.
My Product table (MySQL) looks like this:
Product - productId - Name - Weight - Price (price as on the cover of the item)
Should I make another table for deals:
Deals - dealID - productID (Foreign Key) - discount (fractional value: percentage) - description
For retrieving items:
- q1: Find all products in products with productID = all the productIDs in deals table
- q2: Update the price with discount from the deals table
- q3: return all the products
Is there a better way to do this ? Also, how do I handle the case of deal existing for only a limited time ?
EDIT: I would like to display how much discount we are offering per product. Hence, I need two values per product, original price and the discounted price for the given duration.
I posted a followup to the solution proposed by crontab here