Three paradigms of database

When designing a relational database, follow different specifications to design a reasonable relational database. These different specifications are called different paradigms. Various paradigms are submitted to the specification, and the higher the paradigm, the less the database redundancy.

There are currently six normal forms of relational databases: the first normal form (1NF), the second normal form (2NF), the third normal form (3NF), the Bass-Cod paradigm (BCNF), the fourth normal form (4NF) and the fifth normal form ( 5NF, also known as the perfect paradigm).

Usually we use the first normal form (1NF), the second normal form (2NF), the third normal form (3NF)

 

1. The first normal form (1NF)

 

In the relational model, each column is an indivisible atomic data item.

 

 In the above table, there are multiple attributes in the delivery address column, which does not comply with the principle of atomicity.

After modification:

 

 

2. The second normal form (2NF)

On the basis of 1NF, non-code attributes must completely depend on the candidate code (on the basis of 1NF, some functional dependencies of non-main attributes on the main code are eliminated).

That is, only one type of data can be stored in a table, and several different types of data cannot be stored in the same table.

 

In the above table, the order number and product number are used as the joint primary key, so the unit price has nothing to do with the order number.

After modification:

 

 

3. The third normal form (3NF)

On the basis of 2NF, any non-primary attributes do not depend on other non-primary attributes (eliminate transitive dependencies on 2NF).

For example, in the second paradigm example above, we cannot put the total price in the order table, because the price depends on the order item table, so the total price should be calculated through the order table associated order table.

 

Guess you like

Origin www.cnblogs.com/huqingfeng/p/12711930.html