1. 第三范式(3NF):
一个关系被称为第三范式 (3NF),如果它是 2NF 并且当没有非键属性传递依赖于主键时,即没有传递依赖。它还应满足以下给定条件之一。对于函数依赖 C->D:
- C 应该是一个超级键,并且,
- D 应该是主要属性,即 D 应该是候选键的一部分。
3NF 用于减少数据重复并实现数据完整性。
例子:
对于函数依赖关系为 {L->M, MN->P, PO->L} 的关系 R(L, M, N, O, P):
The candidate keys will be : {LNO, MNO, NOP}
as the closure of LNO = {L, M, N, O, P}
closure of MNO = {L, M, N, O, P}
closure of NOP = {L, M, N, O, P}
这种关系在 3NF 中,因为它已经在 2NF 中并且没有传递依赖。也没有非主要属性派生非主要属性。
2. 博伊斯-科德范式(BCNF):
BCNF 代表 Boyce-Codd 范式,由 RF Boyce 和 EF Codd 在 1974 年提出。 如果这些属性成立,则函数依赖被称为 BCNF:
- 它应该已经在 3NF 中了。
- 对于函数依赖,比如 P->Q,P 应该是一个超级键。
BCNF 是 3NF 的扩展,它比 3NF 有更严格的规则。此外,它被认为比 3NF 更强。
例子:
对于函数依赖关系为 {A->B, A->C, C->D, C->A} 的关系 R(A, B, C, D):
The candidate keys will be : {A, C}
as the closure of A = {A, B, C, D}
closure of C = {A, B, C, D}
这个关系在 BCNF 中,因为它已经在 3Nf 中(没有素数属性派生没有素数属性),并且在函数依赖的左侧有一个候选键。
3NF 和 BCNF 的区别:
S.NO. | 3NF | BCNF |
---|---|---|
1. | In 3NF there should be no transitive dependency that is no non prime attribute should be transitively dependent on the candidate key. | In BCNF for any relation A->B, A should be a super key of relation. |
2. | It is less stronger than BCNF. | It is comparatively more stronger than 3NF. |
3. | In 3NF the functional dependencies are already in 1NF and 2NF. | In BCNF the functional dependencies are already in 1NF, 2NF and 3NF. |
4. | The redundancy is high in 3NF. | The redundancy is comparatively low in BCNF. |
5. | In 3NF there is preservation of all functional dependencies. | In BCNF there may or may not be preservation of all functional dependencies. |
6. | It is comparatively easier to achieve. | It is difficult to achieve. |
7. | Lossless decomposition can be achieved by 3NF. | Lossless decomposition is hard to achieve in BCNF. |