Fish Touching🐟🎣

3NF

Jun 28, 2023

# 3NF

BCNF requires that all nontrivial dependencies be of the form α → β, where α is a superkey.
3NF relaxes this constraint slightly by allowing certain nontrivial functional dependencies whose left side is not a superkey

image.png

# 3NF 分解

  1. 先求出 Canonical Cover Fc
  2. 对于 Fc 里面的所有函数依赖 a->b,均转化为 Ri=ab
  3. 对于所有的模式 Ri
    • 如果包含候选码,进行第 4
    • 如果都不包含候选码, 将任意一个候选码添加到模式 Ri 里面
  4. 如果一个模式被另一个模式包含,则去掉此被包含的模式。

例子关系模式 r(A,B,C,D,E,F), 函数依赖 集 F: A->BCD,BC->DE,B->D,D->A

  1. 函数依赖是:A->BC.B->DE,D->A
  2. R1=ABC,R2=BDE,R3=DA,不包含候选码(AF,BF,DF)中任意一个,所以任意添加一个 R4=AF
  3. 3NF 分解为{ABC,BDE,DA,AF}

# 2NF VS 3NF

  1. 2NF is concerned with eliminating partial dependencies. This means that if a table has a composite primary key (consisting of multiple columns), no column should be dependent on just a part of the primary key. Every non-key attribute should be fully functionally dependent on the whole primary key.
  2. 3NF goes a step further by eliminating transitive dependencies. This means that no non-key attribute should depend on another non-key attribute. Each non-key attribute must be directly dependent on the primary key and only on the primary key.