Database paradigm learning and ER model

First Normal Form ( 1 NF)

: The emphasis is on the atomicity of the field , that is, a field cannot be divided into several other fields.

           

Note: This table structure design does not reach 1 NF. To meet 1 NF, we only need to split the field, that is, split the contact field into name, tel, addr and other fields.

Second Normal Form ( 2 NF)

On the basis of satisfying 1 NF , it also contains two parts: one is that the table must have a primary key. Second, the non-primary key field must be entirely dependent on the primary key, but can not rely only on a part of the primary key.

For example: the primary keys in the OrderDetail table are OrderID (order ID) and ProductID (product ID), UnitPrice (unit price) is constrained by ProductId (product ID), which is partly dependent on the primary key. Similarly, ProductName (product name) is constrained by UnitPrice (order ID) and is partially dependent on the primary key, so it does not meet the requirements of the second normal form.

After modification:

It can be seen that the red boxes in the two tables are the primary key, and the non-primary key fields all depend on the primary key field. Meet the second paradigm.

Third Normal Form (3NF)

The third normal form ( 3 NF): satisfy 2 NF, in addition, non-primary key fields must directly depend on the primary key, and there can be no transitive dependence. That is, it cannot exist: the non-primary key field A depends on the non-primary key field B, and the non-primary key field B depends on the primary key.

Example: OrderID is the primary key in the Order table, and the rest of the fields are directly dependent on the primary key, which satisfies the second normal form. Through observation, it is found that CustomerName (user name) and user address fields are directly dependent on the use of CustomerID (user ID), which indirectly depends on the primary key. Does not meet the third normal form.

After modification:

All non-primary key fields are directly dependent on the primary key field.

ER model

                               

 

Guess you like

Origin blog.csdn.net/qq_39197555/article/details/113920563