how to model discount on items in a database?

前端 未结 4 2072
离开以前
离开以前 2021-02-05 23:30

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
    -         


        
4条回答
  •  青春惊慌失措
    2021-02-06 00:02

    I would use a decimal for the discount column.

    price * discount = $amount off

    price - $amount off = price in cart

    For limited time you could put in a expiration date column, and only return rows that are not expired.

提交回复
热议问题