Principles of Database Systems --- relational database design theory

Relational database design theory

Functional Dependencies

  Note A-> B denotes A decision function B , it can be said B A depends on function .

  If {A1, A2, ...., An } is a set of one or more attributes of the relationship, the set function determines all other attributes and is the smallest , then the set is called the key code .

  For A-> B, if A can find a proper subset of the set A ', is the A' -> B, then A-> B is partially dependent on the function , or is totally dependent function .

  For A-> B, B-> C, then A-> C is a transfer function dependency .

abnormal

  The following is a function of course is dependent on the relationship between students Sno, Cname-> Sname, sdept, Mname. Grade, key code is {Sno, Cname}. That is, after determining the curriculum and students, will be able to determine other information.

Sno come off Sdept Game Cname Grade
1 Students -1 School -1 Dean -1 Course -1 90
2 Students -2 College -2 Dean -2 Courses -2 80
2 Students -2 College -2 Dean -2 Course -1 100
3 Students -3 College -2 Dean -2 Courses -2 95

Does not meet the relationship paradigm, it will have a lot of exceptions, mainly in the following four anomalies:

  • Redundant data: for example, there were two students -2.
  • Exception Review: modifying information in a record, but the other record has the same information has not been modified.
  • To delete an exception: delete a message, it will also lose other information. Such as deleting a course-1, need to remove the first and third lines, the information-1 students will be lost.
  • Insert an exception: for example, you want to insert the information a student, if the student has not elective, then it can not be inserted.

Paradigm

Paradigm theory in order to solve the above-mentioned four kinds of anomalies.

  High-level paradigm relies on low-level paradigm , 1NF is the lowest level of paradigm.

1. The first paradigm (1NF)

  Property can not be separated .

2. The second paradigm (2NF)

  Each non-primary property entirely dependent on the key code .

  It can be met by decomposition.

Decomposition ago

Sno come off Sdept Game Cname Grade
1 Students -1 School -1 Dean -1 Course -1 90
2 Students -2 College -2 Dean -2 Courses -2 80
2 Students -2 College -2 Dean -2 Course -1 100
3 Students -3 College -2 Dean -2 Courses -2 95

Students course the above relationship, {Sno, Cname} key codes, the following functional dependency:

  Sno-> detachable Sdept

  Sdept->Mname

  Sno,Cname->Grade

  Grade entirely dependent on the key code, it has no data redundancy, each course each student has a specific result.

  Sname, Sdept and Mname are partly dependent on the key code, when a student enrolled more than door class, these data will appear several times, causing a large amount of redundant data.

After decomposition

Relate to

Sno come off Sdept Game
1 Students -1 School -1 Dean -1
2 Students -2 College -2 Dean -2
3 Students -3 College -2 Dean -2

The following functional dependencies:

  Sno-> detachable Sdept

  Sdept->Mname

Relations -2

Sno Cname Grade
1 Course -1 90
2 Courses -2 80
2 Course -1 100
3 Courses -2 95

The following functional dependencies:

  Sno,Cname->Grade

3. Third Normal Form (3NF)

  Non-primary property does not depend on the transfer function of the key code .

-1 above relationship following transfer function dependencies:

  Sno->Sdept->Mname

You can make the following decomposition:

Relations -11

Sno come off Sdept
1 Students -1 School -1
2 Students -2 College -2
3 Students -3 College -2

Relations -12

Sdept Game
School -1 Dean -1
College -2 Dean -2
4.BCNF paradigm

  3NF on the basis of, eliminating the properties of the main part of the function key code dependent and dependent transfer function

Guess you like

Origin www.cnblogs.com/yjxyy/p/11129566.html