繁体   English   中英

需要帮助将表格标准化为 3NF?

[英]Need help in normalizing a table upto 3NF?

我想规范化表格到目前为止,我已经这样做了:

我的 3Nf 对吗?

Order(orderNo,orderDate,customerId)

Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress)

Product(productId,productName,Qty,categoryId)

Category(categoryId,categoryName)

Sub-Category(subCatId,subCatName,categoryId)

此处给出表格: https://drive.google.com/file/d/1F7cQjjxz9rnY6RHaGtZXuwVGFEHBVgNo/view

您的非规范化表包含一个会产生歧义的 Qty 字段。 是产品数量还是订单数量?

您必须在 Order 和 Product 之间创建一个连接表,以便跟踪包含多个产品的订单。

Order(orderNo,orderDate,customerId)

Order_Details(orderNo,productId,Qty)

Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress)

Product(productId,productName,Qty,categoryId)

Category(categoryId,categoryName)

Sub-Category(subCatId,subCatName,categoryId)

根据Wiki的定义:如果表在 1NF 中并且没有非主属性依赖于表的任何候选键的任何适当子集,则表在 2NF 中。 您的大多数表格只有 2 列,因此他们对此感到满意。 对于Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress) ,候选键是customerId ,其他列完全依赖于整个候选键,那么就可以了。

对于 3NF, Wiki说:表中的所有属性仅由该表的候选键确定,而不由任何非主属性确定 如您所见,您的桌子都很满意。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM