简体   繁体   English

数据库归一化为3NF

[英]Database Normalization to 3NF

I have to normalize the data below to the 3NF, showing all the stages from UNF to 3NF. 我必须将以下数据归一化为3NF,以显示从UNF到3NF的所有阶段。

在此处输入图片说明

I have made an attempt to it, but am not sure if its correct. 我已经尝试过,但是不确定它是否正确。

1NF 1NF

OwnerName(PK), OwnerAddress(PK), PhoneNo OwnerName(PK),OwnerAddress(PK),电话号码

OwnerName(PK), OwnerAddress(PK), PropertyRef(PK), NrOfBeds, Location, Facilities, WeeksAvailable OwnerName(PK),OwnerAddress(PK),PropertyRef(PK),NrOfBeds,位置,设施,周数

2NF 2NF

Owner(OwnerName(PK), OwnerAddress(PK), PhoneNo) 所有者(OwnerName(PK),OwnerAddress(PK),电话号码)

PropertyOwner (OwnerName(PK), OwnerAddress(PK), PropertyRef(PK)) PropertyOwner(OwnerName(PK),OwnerAddress(PK),PropertyRef(PK))

Property (PropertyRef(PK), NrOfBeds, Location, Facilities, WeeksAvailable) 属性(PropertyRef(PK),NrOfBeds,位置,设施,周数)

3NF 3NF

Owner(OwnerName(PK), OwnerAddress(PK), PhoneNo) 所有者(OwnerName(PK),OwnerAddress(PK),电话号码)

PropertyOwner (OwnerName(PK) , OwnerAddress(PK) , PropertyRef(PK)*) PropertyOwner(OwnerName(PK) ,OwnerAddress(PK) ,PropertyRef(PK)*)

Property (PropertyRef(PK), NrOfBeds, Location, Facilities) 属性(PropertyRef(PK),NrOfBeds,位置,设施)

WeeksAvailable(PropertyRef(PK)*, WeekNr(PK)) WeeksAvailable(PropertyRef(PK)*,WeekNr(PK))

PropertyFacilities(PropertyRef(PK) , FacilityCode(PK) ) PropertyFacilities(PropertyRef(PK) ,FacilityCode(PK)

Facilities(FacilityCode(PK), Desc) 设施(FacilityCode(PK),Desc)

That looks like a reasonable first go. 看起来是一个合理的第一步。 I'm a bit confused by all the PK notations. 我对所有PK表示法都有些困惑。 Does the Owner table really need the Address as part of the PK? 所有者表是否真的需要该地址作为PK的一部分? Also, where did the PropertyOwner come from? 另外,财产所有人来自哪里? What makes it different to Owner? 与所有者有何不同?

Best practice is to give each entity an Id - usually an auto-incrementing integer (IDENTITY in SQL Server), and use that as the PK. 最佳实践是为每个实体赋予一个ID-通常是一个自动递增的整数(SQL Server中为IDENTITY),并将其用作PK。 This means that if say an Owner changes their name the PK itself doesn't change. 这意味着,如果说所有者更改了名称,则PK本身不会更改。

I think some of the PKs you have a really FKs: FacilityCode in PropertyFacilities is really an FK; 我认为您的某些PK确实是FK:PropertyFacilities中的FacilityCode确实是FK。 PropertyRef in that table is also as FK. 该表中的PropertyRef也称为FK。 The PK would be a unique identifier as above. PK将是如上所述的唯一标识符。

Does that make sense? 那有意义吗?

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

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