Home  >  Article  >  Backend Development  >  Database three paradigms, easy to understand_PHP tutorial

Database three paradigms, easy to understand_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:38:35855browse

I have collected a lot of articles on the Internet about understanding database paradigms. They are all copied and pasted from the same article. Even the examples are exactly the same. Please be creative. I really can’t stand it. I will write my own article about understanding the three paradigms. article. If there is any incorrect understanding, please contact me: 279537592#qq.com (#=>@)

Official definition: First Normal Form (1NF): The fields in the database table have a single attribute and cannot be subdivided.
My understanding: Needless to say the first normal form, as long as the relational database satisfies the first normal form

Official definition: Second Normal Form (2NF): There is no partial functional dependence of non-key fields on any candidate key field in the database table
My understanding: In the second normal form, A or B in the combined primary key (AB) [Note: also called composite primary key] cannot be combined with other fields. To solve this problem, the usual approach is that we do not need to combine the primary key. Adding an ID as a single primary key can satisfy the second normal form. If you do not want to add an ID, please ensure that A or B in the composite primary key (AB) cannot be duplicated with other fields.
For example: the second normal form is not satisfied, and the combination of A and field C in the composite primary key is repeated
+----------------+----------+-----------+
pk pk row
+----------------+----------+-----------+
A A B B C
+----------------+----------+-----------+
A A D D C
+----------------+----------+-----------+
A A A C
+----------------+----------+-----------+

Change to this to satisfy the second normal form (but not the third normal form, field A and field C are repeated combinations):
+---------+----------------+-----------+-------------- -----+
pk row row
+---------+----------------+-----------+-------------- -----+
1 1 A A B B C
+---------+----------------+-----------+-------------- -----+
2 +---------+----------------+-----------+-------------- -----+
3 3 A A E E C
+---------+----------------+-----------+-------------- -----+

Official definition: Third Normal Form (3NF): Based on the second normal form, if there is no transitive functional dependence of non-key fields on any candidate key field in the data table, it conforms to the third normal form.
My understanding: In the third normal form, there cannot be combinatorial duplication between fields
For example: the third normal form is not satisfied, the combination of field A and field C is repeated
+---------+----------------+-----------+-------------- -----+---------------+
pk row row
+---------+----------------+-----------+-------------- -----+---------------+
1 1 A A B B C C F
+---------+----------------+-----------+-------------- -----+---------------+
2 +---------+----------------+-----------+-------------- -----+---------------+
3 3 A A E E C C K
+---------+----------------+-----------+-------------- -----+---------------+

Change this to satisfy the third normal form:

Table 1
+---------+----------------+-----------+
pk row row
+---------+----------------+-----------+
1 1 A A B
+---------+----------------+-----------+
2 +---------+----------------+-----------+
3 3 A A E
+---------+----------------+-----------+
and Table 2
+---------+-------------------+----------------+
pk row
+---------+-------------------+----------------+
1 1 C C F
+---------+--

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486482.htmlTechArticleThere are a lot of articles on the understanding of database paradigms collected online, all of which are copied and pasted. The examples are all exactly the same. Please be a little more creative. I really can’t stand it. I...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn