Relational databases: functional dependencies, 3NF paradigm, BCNF paradigm

A functional dependency

Functional dependencies (functional dependency, FD) is an integrity constraint is a constraint relationship between the real world things property, it is widely exists in the real world.

1.1 Functional Dependencies

Here Insert Picture Description

1.2 trivial dependence and non-trivial function

Here Insert Picture Description

1.3 complete and partial functional dependency functional dependency

Here Insert Picture Description
Illustration:
Here Insert Picture Description

  • Totally dependent on
    the student number, course number can uniquely identify a course fraction:
    {studentNo, courseNo} -> Score ;
    can uniquely identify a student number of student name:
    studentNo-> studentName ;
    can be uniquely identified by a program number course name:
    courseNo-> CourseName .
    studentNo, courseNo are {studentNo, courseNo} subset,
    but
    studentNo / courseNo
    can not be uniquely determined Score .
  • 部分依赖
    {studentNo,courseNo}—>studentName;
    {studentNo,courseNo}—>courseName;
    studentNo 、courseNo都是 {studentNo,courseNo}的子集,
    studentNo—>studentName;
    courseNo—>courseName

1.4 传递函数依赖

Here Insert Picture Description
示例说明:
Here Insert Picture Description

  • 传递依赖
    由学生学号可以唯一确定一个班级编号、班级名称、学院名称:
    studentNo—>{classNo, className, institute};
    由班级编号可以唯一确定一个班级名称、学院名称:
    classNo—>{className, institute};
    且由classNo不能唯一确定studentNo
    从上述两个函数依赖关系中可以得出:
    studentNo—>{className, institute},故存在传递依赖。

2 范式(Normal Form)

  基于函数依赖理论,关系模式可分成第一范式(1NF),第二范式(2NF),第三范式(3NF)和 Boyce-Codd 范式(BCNF)。这几种范式的要求一个比一个严格,它们之间的联系为BCNF ⊂ 3NF ⊂ 2NF ⊂ 1NF。即满足 BCNF 范式的关系一定满足3NF范式,满足3NF 范式的关系一定满足2NF范式,满足2NF范式的关系一定满足1NF范式。

1NF Each field corresponding to the attribute values ​​are inseparable
2NF All non-primary attributes are totally dependent on the candidate code
3NF Non-primary property must rely solely on the candidate code and directly dependent on
(allowed transmission property dependence on the primary candidate code and partly dependent)
BCNF Elimination of the main properties of the bond portion of the original transmission dependence relationship

2.1 The first paradigm (1NF) - Code

Here Insert Picture Description

2.2 The second paradigm (2NF) - all codes

Here Insert Picture Description

2.3 The third paradigm (3NF) - only Code

Here Insert Picture Description
Here Insert Picture Description

2.4 Boyce-Codd paradigm (the BCNF)

Here Insert Picture Description
Meet BCNF conditions:

  • All non-primary attributes are fully dependent on the function of each of the candidate key;
  • All main attributes are fully dependent on the function of each of the candidate key does not contain it;
  • No function is completely independent of any property of a set of non-candidate key attributes.
Published 50 original articles · won praise 38 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_42250302/article/details/103111134