Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 规范化传递依赖_Sql_Relational Database_Database Normalization - Fatal编程技术网

Sql 规范化传递依赖

Sql 规范化传递依赖,sql,relational-database,database-normalization,Sql,Relational Database,Database Normalization,我需要正常化方面的帮助。我很难理解如何完成数据库项目中的3NF。这是你的电话号码 1NF Donut ID(PK) Donut Name Description Unit Price Donut Order ID Qty CustomerID Last Name First Name Last Name Street Address Apt City State Zip Home Phone Mobile Phone Other Phone Order Date Special Notes

我需要正常化方面的帮助。我很难理解如何完成数据库项目中的3NF。这是你的电话号码 1NF

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
规范化表

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
2NF 甜甜圈桌

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
销售订单表

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
销售订单行项目表

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes

我的问题是摆脱3NF中的可传递依赖关系。在我的第四个表中,如果没有主键,我会使用什么属性,这样就没有多余的东西或相互依赖的东西?任何指示都将不胜感激

销售订单表对客户的名称和地址具有可传递的依赖关系。如果仔细观察,您会发现每个订单都会包含给定客户的完整地址和姓名信息,即使这些信息可能不会随着订单的变化而变化。要解决此问题,您可以将此信息移动到新的
Customer
表中,该表将包含以下字段:

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
客户表

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes

销售订单
表将变成:

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes
销售订单表

Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes

请注意,订单日期可以保留在
销售订单
表中,因为从概念上讲,它代表每个订单发生时的时间戳,是该特定订单独有的。

噢,哇,谢谢你,这完全有道理!除了我忘了在2NF中输入订单日期。让我来编辑一下,对不起,我是编程新手。说真的,我现在可以吻你了!!我为此绞尽脑汁好几个小时了。
Donut ID(PK)
Donut Name
Description
Unit Price
Donut Order ID
Qty
CustomerID
Last Name
First Name 
Last Name 
Street Address
Apt
City
State
Zip
Home Phone
Mobile Phone
Other Phone
Order Date 
Special Notes