[英]Need help in normalizing a table upto 3NF?
I want to normalize the table So far i have done this:我想规范化表格到目前为止,我已经这样做了:
is it my 3Nf correct?我的 3Nf 对吗?
Order(orderNo,orderDate,customerId)
Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress)
Product(productId,productName,Qty,categoryId)
Category(categoryId,categoryName)
Sub-Category(subCatId,subCatName,categoryId)
Given table here: https://drive.google.com/file/d/1F7cQjjxz9rnY6RHaGtZXuwVGFEHBVgNo/view此处给出表格: https://drive.google.com/file/d/1F7cQjjxz9rnY6RHaGtZXuwVGFEHBVgNo/view
Your unnormalized table contain a Qty field which creates ambiguity.您的非规范化表包含一个会产生歧义的 Qty 字段。 Is it product quantity or quntity of order?
是产品数量还是订单数量?
You have to make a junction table between Order and Product in order to keep track of orders that contain more than one product.您必须在 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)
Base on the definition from Wiki : a table is in 2NF if it is in 1NF and no non-prime attribute is dependent on any proper subset of any candidate key of the table .根据Wiki的定义:如果表在 1NF 中并且没有非主属性依赖于表的任何候选键的任何适当子集,则表在 2NF 中。 Most of your tables only have 2 columns, so they satisfied this.
您的大多数表格只有 2 列,因此他们对此感到满意。 For
Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress)
, the candidate key is customerId
, and the other columns completely depend on the whole candidate key, then it's OK.对于
Customer(customerId,customerName,customerCurrentAddress,customerPermanentAddress)
,候选键是customerId
,其他列完全依赖于整个候选键,那么就可以了。
For 3NF, Wiki said: all the attributes in a table are determined only by the candidate keys of that table and not by any non-prime attributes .对于 3NF, Wiki说:表中的所有属性仅由该表的候选键确定,而不由任何非主属性确定。 As you see, your tables are all satisfied.
如您所见,您的桌子都很满意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.