数据库关系规范化

2018-06-23  本文已影响0人  祭祀WO菛僾_3930

关系规范化中的4个问题

范式

1NF: 属性不可分
第二范式(2NF):符合1NF,并且非主属性完全依赖于码。(更通俗说有主键ID))
第三范式(3NF):符合2NF,并且,消除传递依赖。(3NF是对字段冗余性的约束,即任何字段不能由其他字段派生出来,它要求字段没有冗余)

四种范式之间关系

部分函数依赖(partial functional dependency)和完全函数依赖(full functional dependency)

部分函数依赖是指如果X→Y,并且存在X的一个真子集X0,使得X0→Y,则称Y对X部分函数依赖

部分函数依赖

完全函数依赖是指指如果X→Y,并且不存在任何一个X的一个真子集X0,使得X0→Y,则称Y对X完全函数依赖。

如果非主属性B函数依赖于主属性A,而且A的任何一个真子集不能->B,则称B完全函数依赖于A;反之,若A的存在一个真子集能->B,则称B完全函数依赖于A。

例:成绩表(学号,课程号,成绩)关系中,
完全函数依赖:(学号,课程号)→ 成绩,学号 -\→ 成绩,课程号 -\→ 成绩,所以(学号,课程号)→ 成绩 是完全函数依赖

传递函数依赖(Transitive functional dependency)

In Database Management System, a transitive dependency is a functional dependency which holds by virtue of transitivity. A transitive dependency can occur only in a relation that has three or more attributes. Let A, B, and C designate three distinct attributes (or distinct collections of attributes) in the relation. Suppose all three of the following conditions hold:

  1. A → B
  2. It is not the case that B → A
  3. B → C

Then the functional dependency A → C (which follows from 1 and 3 by the [axiom of transitivity]) is a transitive dependency.

In database normalization, one of the important features of third normal form is that it excludes certain types of transitive dependencies. E.F. Codd, the inventor of the relational model, introduced the concepts of transitive dependence and third normal form in 1971.

Example

A transitive dependency occurs in the following relation:

The functional dependency {Book} → {Author Nationality} applies; that is, if we know the book, we know the author's nationality. Furthermore:

Transitive dependency occurred because a non-key attribute (Author) was determining another non-key attribute (Author Nationality).

上一篇 下一篇

猜你喜欢

热点阅读