1

Hello I have many to many relationship. I learning normalization rules. I add quantity because quantity column is used only for products associated with the invoice. My question is: Can I add extra column in junction table? Is it OK to normalization rules or is there a better solution?

enter image description here

4
  • 1
    I add quantity because quantity column is used only for products associated with the invoice. This means that the "relation" between product and invoice is separate entity, with its own attributes. The analysis you performed contains error(s) somewhere. It is probably that you mix "product as pattern" and "product portion related to invoice as instance" into one entity. From the other side in theory nothing prevents the relation to have its own attibutes.
    – Akina
    Commented Nov 27, 2020 at 17:34
  • Sorry, but I didn't understand. Can you design a correct diagram for me? It will be much more understandable on the diagram. Commented Nov 27, 2020 at 17:37
  • You want me to create a diagram without complete knowledge about subject area to be modelled? I can't do that.
    – Akina
    Commented Nov 27, 2020 at 17:42
  • I have invoices and products. I have "create invoice" page in website. I have invoice product list table in create invoice page. I add product more than one to invoice. Quantity column is not product feature. Quantity column is invoice products feature. I can't add column in product table because quantity column belongs to invoice products. Quantity changes in each invoice product. Commented Nov 27, 2020 at 17:56

2 Answers 2

4

yes you can add columns to a bridge table, as long as they are attributes to that for that relationship.

Customers     CustomerProducts      Products

customerId    customerId            productId
              productId
              price
              quantity
              buyDate

The columns price, quantity and buy_date, are all specific to the that entry

2
  • No problem for normalization rules, got it right? Commented Nov 27, 2020 at 17:18
  • 1
    yes ot is no problem
    – nbk
    Commented Nov 27, 2020 at 17:20
0

Having a table with 2 foreign keys plus extra columns is absolutely normal. The only question I see would be whether such a table can be called a "junction table". This Microsoft article implies (at point #4) that it can.

1
  • I dont think this adds anything to the previous answer. Commented Aug 1, 2023 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.