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?
-
1I 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.– AkinaCommented 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.– Fırat KayaCommented 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.– AkinaCommented 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.– Fırat KayaCommented Nov 27, 2020 at 17:56
Add a comment
|
2 Answers
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
-
-
1
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.
-
I dont think this adds anything to the previous answer. Commented Aug 1, 2023 at 20:40