I'm currently making an ER diagram for my product model. But I'm confused that the DISCOUNT needs an entity to connect with the product module or it can just be an attributes of the product? my current product module: the
PRODUCT
PRODUCT_ID(PK)
PRODUCT_NAME
PRODUCT_PRICE
PRODUCT_TYPE
PRODUCT_COLOUR
PRODUCT_SIZE
STOCK_UNIT (FK)
this is the entity i try to make for DISCOUNT
PRODUCT_ID (PK,FK)
ADMIN_ID(FK)
DISCOUNT_DATE
DISCOUNTED_PRICE
In my scenario, some of the specific product prices can be discounted with value/ per centage. But I am confused that do i need to put the discount value/percentage as an attribute or an entity in the product module because there are only some products that have the discounted price.
I hope that my explanation is clear enough ><
CodePudding user response:
Based on question and comments, I suggest:
Discount Table
--------------
DISCOUNT_ID (PrimaryKey)
PRODUCT_ID (ForeignKey)
IsPERCENT (Bool)
DISCOUNT (Float|Double)
FROM_DATE (DateTime)
TILL_DATE (DateTime)
IsPercent
should be True if discount is to calculated using Percentage.
Discount
should be value (treated as percent or Currency depending on IsPercent)
Also in your program, validate that Discount
value doesn't go above 100 if IsPercent
is TRUE