数据库规范化SQL

时间:2019-03-18 06:57:11

标签: database-design relational-database database-normalization

我需要将此表标准化为第三范式。清楚地显示0NF,1NF,2NF和3NF的阶段。 陈述您可以做的任何假设使用关系符号。`Normalisation

我在此任务中做了以下假设:' 已经确定一个主人可以养多只宠物。 一只宠物可以散步。

ONF R1 = (Owner #, Owner Name, Owner Phone, {Pet#, Pet Name, Walk Date, Walk Duration, Paid, Walk Notes})

1NF-

R11 = (Owner #, Owner Name, Owner Phone)
R12 = (Pet #, Owner #, Pet Name, Walk Date, Walk Duration, Paid, Walk Notes)

2NF
R11 = (Owner #, Owner Name, Owner Phone)
R12 = (Pet #, Owner #, Pet Name, Walk Date, Walk Duration, Paid, Walk Notes)
R121 =(Pet #, Owner #, Pet Name)
R122 = (Pet #, Walk Date, Walk Duration, Paid, Walk Notes)

3NF
Already in 3NF as no transitive dependencies exist.

只想看看这是否正确?

1 个答案:

答案 0 :(得分:0)

您没有任何传递依赖,但是

---所有初始关系都在0NF中

--- 1NF:

每个表格单元格应包含一个值。

每条记录都必须是唯一的。

--- 2NF,应将步行和宠物分开,以避免冗余: 因为如果您插入新宠物而没有步行会话,您将有4列没有价值。换1000只新宠物会不好。 更新和删除步行会话太糟糕了

R1 = (Owner#, Owner Name, Owner Phone)
R2 = (Pet#, Pet Name,Paid, Owner#,Walk#)
R3 = (Walk#, Walk Date, Walk Duration, Walk Notes)