Note:
The table is called the relationship in the definition, remembering R
Fields are called attributes in definitions
Mode: There are three modes, external mode, internal mode, mode in the database.
Bold is the meaning of keyword
Bertarant
First paradigm
Definition: If all the values of all attributes in the relational r are simple domains, then the relationship mode R is the first paradigm.
Then there is the characteristics of the first mode.
1) Have a primary keyword
2) The primary key cannot be empty.
3) The primary key cannot be repeated.
4) Fields can not be divided
E.g:
StudyNO | Name | SEX | Contact
20040901 John Male Email: KKKK @ EE.NET, Phone: 222456
20040901 Mary Famale Email: Kkk@fff. Net Phone: 123455
The above table does not meet, the first paradigm: Primary key repetition (actually database is not repeated), and the Contact field can be divided
So the change is correct.
StudyNO | Name | SEX | Email | Phone
20040901 John Male Kkkk@ee.net 222456
20040902 Mary Famale Kkk@fff .NET 123455
Second paradigm:
Definition: If the relational mode R is the first paradigm, and each non-primary attribute in the relationship does not partially depend on the primary key, R is the second paradigm.
Therefore, the main task of the second paradigm is
Under the premise of the first paradigm, the partial function is eliminated.
StudyNO | Name | SEX | Email | Phone | Classno | ClassAddress
01 John Male Kkkk@ee.Net 222456 200401 A floor 2
01 Mary Famale Kkk@fff.net 123455 200402 A Building 3
This table is fully satisfied with the first paradigm.
The primary key consists of Studyno and Classno, so that it can be positioned to the specified line.
However, the ClassAddress part depends on keywords (Classno-> ClassAddress),
So becoming two tables
Table I
StudyNO | Name | SEX | Email | Phone | Classno
01 John Male Kkkk@ee.net 222456 200401
01 Mary Famale Kkk@fff.net 123455 200402
Table II
Classno | ClassAddress
200401 A floor 2
200402 A floor 3
Third paradigm:
Under the premise of meeting the second paradigm, eliminate delivery dependencies.
example:
StudyNO | Name | SEX | Email | Bounslevel | Bouns
20040901 John Male Kkkk@ee.net excellent $ 1000
20040902 Mary Famale Kkk@fff.net Good $ 600 This is completely satisfied with the second paradigm, but Bounslevel and Bouns are delivered dependent.
change to:
StudyNO | Name | SEX | Email | Bouunsno
20040901 John Male Kkk@ee.net 1
20040902 Mary Famale Kkk@fff.net 2
Bounsno | Bounslevel | Bouns
1 excellent $ 1000
2 Good $ 600
Here I prefer to use BounsNo as the primary key.
Based on two reasons
1) Do not use characters as the primary key. Some people may say: If my level is replaced by value?
2) But if the level name is changed, it is not called 1, 2, 3 or excellent, good, so it can be easily changed, so I usually use the field-independent field as a keyword.
Generally satisfying the first three paradigms can avoid data redundancy.
Fourth paradigm:
Main tasks: Eliminate multi-valued dependence on the premise of the third paradigm
Product | Agent | Factory
Car A1 F1
Bus A1 F2
Car A2 F2
Here, the position of the Car must be obtained by the Agent and Factory (so the primary key consists of Agent and Factory), can rely on the Agent and Factory attributes via Product.
So is correct
Table 1 Table 2:
Product | Agent Factory | Product
Car A1 F1 Car
Bus A1 F2 Car
Car A2 F2 BUS
Fifth paradigm:
Definition: If each connection depend on the relational mode r is contained by the candidate key of R, R is the fifth paradigm
See the definition, you know that it is necessary to eliminate connection dependencies and must guarantee the complete data.
example
A | B | C
A1 B1 C1
A2 B1 C2
A1 B2 C1
A2 B2 C2
If you want to locate a particular row, you must do three properties for keywords.
Therefore, the relationship should be three relationships, which are A and B, B and C, C and A.
as follows:
Table 1 Table 3
A | B B | C c | a
A1 B1 B1 C1 C1 A1
A1 B2 B1 C2 C1 A2
The paradigm can avoid data redundancy, reduce the space of the database, reduce the trouble of maintaining data integrity, but the operation is difficult because you need to contact multiple tables to get the required data, and the higher the paradigm. It is more troublesome to trade out whether it is more troublesome. Generally, I am doing the project, the most used is the third paradigm, I think it is enough to use the third paradigm, good performance.
And convenient management data