Database three paradigm, easy to understand

Source: Internet
Author: User

 

I have collected a lot of articles on understanding the database paradigm on the Internet, all of which are copied and pasted. Even the examples are the same. Please be creative. I can't see them anymore, write an article on understanding the three paradigms by yourself. If your understanding is incorrect, contact me: 279537592 # QQ.com (#=> @)

Official definition: 1nf: fields in database tables are single attributes and cannot be classified.
My understanding: the first paradigm does not need to be mentioned. As long as relational databases meet the first paradigm

Official definition: Second Paradigm (2nf): Some function dependencies of non-Keyword fields on any candidate keyword fields in database tables
In my understanding: In the second paradigm, the combination of A or B in the primary key (AB) [Note: Also called a composite primary key] cannot overlap with other fields. To solve this problem, generally, we do not need to combine primary keys and add an ID. As a single primary key, the second paradigm can be satisfied. If you do not want to add an ID, either A or B in the combination primary key (AB) cannot be duplicated with other fields.
For example, if the second paradigm is not met, the combination of a and field C in the composite primary key is repeated.
+ ------------ + ----------- + ------------------- +
PK row
+ ------------ + ----------- + ------------------- +
A B C
+ ------------ + ----------- + ------------------- +
A D C
+ ------------ + ----------- + ------------------- +
A e c
+ ------------ + ----------- + ------------------- +

This satisfies the second Paradigm (but does not meet the third paradigm, and the combination of field a and field C is repeated ):
+ --------- + ------------ + ----------- + ------------------- +
PK row
+ --------- + ------------ + ----------- + ------------------- +
1 A B C
+ --------- + ------------ + ----------- + ------------------- +
2 A D C
+ --------- + ------------ + ----------- + ------------------- +
3 a e c
+ --------- + ------------ + ----------- + ------------------- +

Official definition: third paradigm (3nf): Based on the second paradigm, if the data table does not have a transfer function dependency for any candidate keyword segment without a non-Keyword segment, it complies with the third paradigm.
My understanding: In the third paradigm, fields and fields cannot be combined repeatedly.
For example, if the third paradigm is not met, the combination of field a and field C is repeated.
+ --------- + ------------ + ----------- + ------------------- + --------------- +
PK row
+ --------- + ------------ + ----------- + ------------------- + --------------- +
1 a B C f
+ --------- + ------------ + ----------- + ------------------- + --------------- +
2 A D C G
+ --------- + ------------ + ----------- + ------------------- + --------------- +
3 A E C K
+ --------- + ------------ + ----------- + ------------------- + --------------- +

To meet the third paradigm:
Table 1
+ --------- + ------------ + ----------- +
PK row
+ --------- + ------------ + ----------- +
1 A B
+ --------- + ------------ + ----------- +
2 A D
+ --------- + ------------ + ----------- +
3 A E
+ --------- + ------------ + ----------- +
And table 2
+ --------- + ----------------- + ------------ +
PK row
+ --------- + ----------------- + ------------ +
1 C f
+ --------- + ----------------- + ------------ +
2 C G
+ --------- + ----------------- + ------------ +
3 C K
+ --------- + ----------------- + ------------ +

Principle: When the combination of fields and fields is repeated and the combination of A and C is repeated, you must first consider splitting them into two tables, whether C is split to table 1 or a is split to Table 1 depends on the situation.

The key is to understand that the main purpose of defining this paradigm standard is to reduce data redundancy. The essence of data redundancy is that there is one-to-many or many-to-many relationship between fields in a table. The database design meeting the third paradigm can be easily implemented by solving the relationship between several pairs.
 

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.