Search code examples
mysqldatabasenormalizationentity-relationshipdatabase-normalization

Entity-Relationship Diagram Redundancy: store, product, orders, categories


I'm trying design a model which allows a user to be a buyer and seller with a single account, but some teachers told me that this diagram is wrong because it has redundancy.

I had reviewed the diagram but I haven't found a way to solve this redundancy. In the table orders I need to know who is a buyer, so for this reason I didn't delete this from the table. Some ideas?

enter image description here


Solution

  • The only thing that are "redundant" (not normalized to be exact) in your scheme is this :

    link table

    You don't need to make a special ID, a composite PK is enough.

    -------------------
    |   ORDERPRODUCT  |
    -------------------
    | PK | PRODUCT_ID |
    | PK | ORDER_ID   |
    -------------------
    
    ADD CONSTRAINT pk 
    PRIMARY KEY (PRODUCT_ID, ORDER_ID);