Basic concepts of database paradigm

Link to this article: https://blog.csdn.net/xiaodongdonglht/article/details/93205275
relational database design, follow certain specifications, the purpose is to reduce data redundancy and data consistency, the current industry paradigm has : First
Normal Form (1NF), Second Normal Form (2NF), Third Normal Form (3NF), Bass-Cod Normal Form (BCNF), Fourth Normal Form (4NF), and Fifth Normal Form (5NF).
The fundamental purpose of using the paradigm is to reduce data redundancy, try to make each data appear only once, and get the final data by joining when getting the data.
Basic Concepts of Paradigm
1 Functional Dependence
Given an X, Y must be found. That is Y Dependency and X, write X → Y.
2 Complete functional dependence
In a table, if X → Y, and for any true subset of X (if the attribute group X contains more than one attribute), X '→ Y is not true, then we call Y complete functional dependence on X,
for example
(Student number, course name)-> The score can determine the score, but the score cannot be determined based on either the student number or the course name. This is called complete dependence.
Part 3 function dependence.
If the Y function depends on X, but At the same time, Y does not completely depend on the function of X, then we call the Y part of the function dependent on X, remember: insert the picture description here. The
opposite of the above concept is
simple. (Student number, class name) → Department name , Student number → department name, then (student number, class name) p → department name.
As long as one of the student number and the class name can be determined to the department name, we will say that part of the function depends on
4. The transfer function depends on
If the Z function depends on Y, and the Y function depends on X, and Y is not included in X, and X does not depend on Y, then we call the Z transfer function dependent on X, remember: insert the picture description here for
simplicity , Department name → department head, student number → department name, then student number T → department head.
This is easy to understand because C can find B according to B and A, then A can find C, which is a transfer function dependency

After talking about some functional dependencies, the following begins to introduce what is paradigm
3.1.3 One-paradigm
One-paradigm (1NF): The domain should be atomic, that is, each column of the database table is an indivisible atomic data item.
Domain: The domain is the range of values ​​of the column. For example, the domain of gender is (male, female) and
it cannot be distinguished. For example, given a gender, the value is really unknown. This is non-conformance.
Second Normal Form (2NF): On the basis of 1NF, the attributes of an entity are fully functionally dependent on the primary key (mixed primary key), and there cannot be some functions that depend on the primary key (mixed primary key).
If there are certain attributes that only depend on some attributes in the mixed primary key, then it does not conform to the second normal form.
The score of the course
taken by the head of the department where the student ID name belongs 20170901176 Wang Xiaoqiang Department of Computer Ma
Xiaoteng000001 95 20170901176 Wang Xiaoqiang Department of Computer Ma Xiaoteng000002 99
The head of the department whose appearance name can be found according to the student ID Conform.
The above table is a mixed primary key (student ID + course taken), but the two attributes of department and department head only depend on the attribute of student ID in the mixed primary key, so it does not conform to the second normal form.
If one day the student ’s department needs to be adjusted, both the department and the department head need to be modified. If the student has taken multiple courses, the rows of data in the table must be modified, which is very troublesome and does not meet The second paradigm.
In order to eliminate this partial dependency, there is only one way to split the big data table into two or more smaller
data tables.
3.1.5 Three-paradigm
3NF On the basis of 2NF, the transitive dependence of non-primary attributes on the primary key (composite primary key) is eliminated.

Order ID Product ID Product Color Product Size Merchant ID User ID

001 0001 Space gray 30027040 XXX flagship store 00001
is obvious. In Table 3-7, the product color depends on the product ID, and the product ID depends on the order ID. Then the delivery of the non-primary product color depends on the order ID, so it does not meet the three Paradigm, the solution is to split the big data table into two or more smaller data tables.
Table 3-7 Table design conforming to the three paradigms (1)

Order ID Product ID Merchant ID User ID

001 0001 XXX flagship store 00001

Product ID Product Color Product Size

0001 Space gray 30027040

Published 19 original articles · won 7 · views 584

Guess you like

Origin blog.csdn.net/liu201812/article/details/102641995