Mysql design specification

Let's introduce the first normal form, second normal form and third normal form of database model design. The

database normal form generally satisfies the third normal form

. (1) The 
definition of the first normal form (no repeated columns): each column of the database table is indivisible Atomic data items, not non-atomic data items such as collections, arrays, records, etc.
If an attribute in the entity has multiple values, it must be split into different attributes. 

Common understanding: a field only stores one piece of information. 

For Example:

Class: Class 1 in the third year of high school, it should be changed to 2 fields, a grade, Only a class can satisfy the first normal form  . It

does not conform to the first normal form:
the student number name class
0001 Xiaohong Class 1 of the third year of high school

should be changed to

the student number name, grade class
0001 Xiaohong, class 1 of the third year of high school

(2) Second normal form (attributes are completely dependent on Definition of primary key) 
: The premise of the first normal form is satisfied, and when there are multiple primary keys, the situation that does not conform to the second normal form will occur.
For example, if there are two primary keys, such an attribute cannot exist. It only depends on one of the primary keys, which is not in line with the 

popular understanding of the second normal form: any field only depends on the same field in the table. 

For Example:

student loan table, Does not meet the  Second Paradigm Student
ID Name Student ID Number Student ID Processing Time Library Card Name Library Card Number Card table: library card library card number library card pulls you in time (3) third normal form (attributes cannot transitively depend on the main attribute) 










定义:满足第二范式前提,如果某一属性依赖于其他非主键属性,而其他非主键属性又依赖于主键,那么这个属性就是间接依赖于主键,这被称作传递依赖于主属性。 

通俗理解:一张表最多只存2层同类型信息 

For Example:

爸爸资料表,不满足第三范式
爸爸儿子 女儿女儿的小熊女儿的海绵宝宝

应改为 

1.爸爸信息表:
爸爸儿子女儿

2.女儿信息表:
女儿女儿的小熊 女儿的海绵宝宝

总结:在业务设计、数据拆分时,会使用到数据库范式,尽可能在业务设计的时候就要遵守范式,请大家自行根据需求设计数据库表。

 

来源:http://blog.csdn.net/flying_ants/article/details/23350031

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326653510&siteId=291194637