定义
prime attribute:candidate key 的其中一个attribute
2NF
定义
(基于1NF基础之上)
对于所有 $X\rightarrow Y$,
- 假如 $Y$ 不是 prime attribute,他的所有$X$绝不可以是任何一个candidate key 的subset
- Every non-prime attribute should no partially dependent on any candidate key
- 换而言之,若要满足2NF:
- 「如果 $Y$ 不是 prime attribute」 && 「$X$ 是 prime attribute」则:
- 「如果$Y$是prime attribute」
例子:
- R: {A, B, C, D}
- Candidate Key: {A, B}
- 只能存在
- {A, B} → C
- {A, B} → D
- C → D, D → C (Transitive Dependency)
- D → A, D → B, D → {A, B}
- C → A, C → B, C → {A, B}
- 不允许存在:
- A → C, A → D (A 不是完整 candidate key)
- B → C, B → D
理解
因为如果$Y$依赖了一个非完整的 candidate key,我们完全可以把 $X_\text{ incomplete candidate key} \rightarrow Y$拆出来作为一个新的表;但是$X_\text{ non-prime attribute} \rightarrow Y$ 则不用拆
3NF