簡體   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