Thinking while learning--analysis of function dependency and multivalued dependency in database

Source: Internet
Author: User

Let's review what is a function : A function is a correspondence between sets (which I like to understand)

The figure shows the single-shot, full-shot, and double-shot in the function. In short, it is the correspondence of the set, and the values in the collection generally satisfy one-to-many relationships, and there cannot be a one-to-many relationship.


Based on the understanding of the functions above, we give a definition of function dependencies :

set R (U) is the relationship pattern on the attribute set U, x, Y is a subset of U, if any one possible relationship to R (U) r,r the value of the attribute on X is equal to two ancestors , The attribute values in Y are not equal to x→y. In short, when a function dependency is a property set that determines another set of properties, it is said that another property set relies on that set of properties. (In fact, there is no one-to-many relationship)

We first distinguish between the three relationships of function dependencies and attribute set attributes

Set R (U) is the relationship pattern on the attribute set U, and X, Y is a subset of U:

If there is a 1:1 relationship between X and Y (one-to-a-relationship), such as a 1:1 relationship between the school and the headmaster, there is a function dependency x→y and y→x.

If there is a 1:n relationship between X and Y (a one-to-many relationship), such as the 1:n relationship between age and name, there is a function dependency y→x.

If there is a m:n relationship between X and Y (many-to-many relationships), such as a m:n relationship between the student and the course, X and

With mathematical mapping relationships, such as f (x) =2x;f x x, Y, and so on, the variables in the function correspond to the XS in the U, and all the values in the X are composed of y after the operation of the function relationship.

Second, function dependencies include the following

1. Trivial function dependencies

When the attribute set Y in a relationship is a subset of the attribute set X, there is a function dependency x→y, a set of property functions that determine all of its subsets, a function dependency called trivial function dependency.

2. Non-trivial function dependencies

When the attribute set Y in a relationship is not a subset of the attribute set X, there is a function dependency x→y, which is called a non-trivial function dependency.

3. Full function dependencies

Set X, Y is a set of two attributes of the relationship R, and the X→Y is the true subset of X, but there is X '!→y for each x ', then the Y full function is dependent on X.

4. Partial function dependencies

Set X, Y is a set of two attributes of the relationship R, there is x→y, if X ' is a true subset of x, there is X ' →y, then the Y function is called X.

5. Transfer function dependencies

X, Y, Z is a different set of attributes in the relationship R, there is x→y (Y!→x), y→z, then the function is said to be dependent on X. (if y→x, then x→z was established)

Use an example to understand the above definition (a-\→b means that a does not depend on B)


Table of students (school number, name, gender, age, college)

Let's say we don't allow duplicate names on tables.

School number → gender, study number → age, study number → college, study number ← name, name → gender, name → age, name → College, but gender-\→sage

--------------------------------------------------------------------------------------------------------------- --

Table 2--Student Courses (school number, course, results)

Study number → course, (school number, course) → Results

--------------------------------------------------------------------------------------------------------------- --

Table 3--Faculties (school number, department name, dean)

School Number → Department name, department name → Department head


In the above example:

Trivial function Dependence: (study number, course) → study number, (study number, course) → course.

Because school numbers and courses are a subset of (study number, course).

Non-trivial function dependence: (study number, course) → results (the database is more discussed in the non-trivial function dependence, and trivial meaning is not small)

Because grades are not a subset of (study number, course).

Partial function Dependency: (school number, name) → Gender

Because (school number, name) → Gender and school number → Gender

Full function Dependency: (school number, course number) → Score

Because (study number, course number) → results, study number-\→ results, course number-\→ results.

Transfer function Dependency: study number → Department director

Because study number → department name, department name → Department director and department name-\→ School number.

And what about multi-valued dependencies? Give a definition

Definition of Multi-valued dependencies :
Set R (U) is a relational pattern on a property set U, X, Y, and Z are subsets of U, and z=u-x-y, multivalued dependent x->->y is established when and only if any relationship to R r,r on (x,z) corresponds to a set of Y values, This set of values is determined only by the X value and is independent of the z-value.
If x->->y, and z= empty set, it is called x->->y is a trivial multi-valued dependency. Otherwise, the x->->y is called a non-trivial multivalued dependency.

Is still understood by the mapping of the function, introducing f (x, y), assuming F (x, y) =+-(x^), if Z=f (x, y), an X value can be obtained two reciprocal number of Z. In this two-tuple function relationship, the value of y actually does not affect the result. Analogy to the relationship pattern, that is, x is the attribute value of the X-set, y is the attribute value of the Y-set, z is the attribute value of the z-set.

Take a look at an example

(Course c)-(Teacher T)-(reference book B)

Database probability-Gu teacher--mathematical analysis
Database probability-Gu teacher--Advanced algebra
Database probability-Gu teacher-Differential equation

The above example U{c,t,b}, where course C and teacher T uniquely determine a group of B, but not related to T, through C, but T is not an empty set, so the non-trivial multi-valued dependency.

In fact, when T is empty, if each value in C corresponds to a certain value in B, it becomes a function dependency, so a function dependency is a special case of multivalued dependency.


Total under:

1. A function dependency does not refer to the constraints that are satisfied by one or some of the relationship instances of the relationship pattern R, but rather to the constraints that all relationship instances of R satisfy.

2. Functional dependency is the concept of semantic category. function dependencies can only be determined based on the semantics of the data. (for example, "name → age" This function depends only on conditions that are not allowed to have the same celebrity)

3. Function dependencies are usually drawn out in a collection for discussion.

4. The Database Designer formulates the function relationship according to the requirements. For example , "name → age" is considered feasible in a particular table.

5. The Database Designer makes the mandatory requirements according to the actual rules. For example, the rule does not allow celebrities to appear, the function depends on "name → age" is established. The tuple being inserted must meet the requirements

function dependency, and if a celebrity exists, it refuses to load the tuple.




Thinking while learning--analysis of function dependency and multivalued dependency in database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.