Which ERD is more correct re proper Database Design?

ERD #1

ERD 1

or

ERD #2

ERD 2

Please explain why one is more correct than the other.

有帮助吗?

解决方案

In my opinion ERD #1 is a better design.

Reasons

Orders/Product Table will have OrderID for a particular Order and for each Product Orderd and quantity for that product for each Order. no repetition/No redundant data.

ERD #2

Is a poor design as each order can have multiple products and you will be adding the same orderid, CustomerID, Invoicedetails for multiple products for the same Order, in simple words more redundant data.

Edit

ERD #2 also violates the database normalization rules. In orders Table you have InvoiceID and then Invoice_Creation_Date which only depends on the InvoiceID .

normalization rules say if a column in a table doesnt directly depend on the Primary Key in that column it should be in a separate table. In other words all the columns in a table should Directly depends on Primary key only.

其他提示

  1. In ERD 1 you can only have one item per order -- hence the need for a join table in ERD2
  2. ERD2 - Why would you have a FK in the invoice table for order_ID, and also have invoice_ID in the order table. One FK field is enough. I assume this is a one order to many invoices, in which case you would put the order_ID in the invoice table

ERD2 is written incorrectly the foreign key Order_ID_FK should be removed from Invoices. Therefore, Invoices should have a one to many relationship with Orders.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top