ITPub博客

首页 > 数据库 > MySQL > 三范式

三范式

MySQL 作者:pentium 时间:2020-02-26 22:16:03 0 删除 编辑

First Normal Form

A table is not in first normal form if it is keeping multiple values for a piece of   information.

 

Second Normal Form   (确定主键)

A table is in second normal form if it is in first normal form AND we need all the fields in the key to determine the values of the non-key fields.

第二范式含义就是主键确定表里余下行的所有字段。例如如果是联合主键,不能是联合主键里的某一部分就能确定余下的字段值,例如联合主键是empID and projNum ,想要知道proName, 只要知道 projNum 就可以了,不需要知道empID

If a table is not in second normal form, remove those non-key fields that are not dependent on the whole of the primary key. Create another table with these fields   and the part of the primary key that they do depend on.

如果一个表不满足第二范式,移动那些不依存主键的字段到其它表去。

Third Normal Form   

(确定外键,把字段依存一个非主键的移走,这个被依存的非主键就是外键了,例如员工表里有部门id,部门名称,就不满足第三范式,部门名称依存部门 id, 其实部门 id 可以作为外键

A table is in third normal form if it is in second normal form AND no non-key fields   depend on a field(s) that is not the primary key.

第三范式是满足第二范式,并且没有其它非主键字段依存其它非主键字段。意思就是 非主键字段必须预存主键字段,如果依存另个非主键字段,则不满足,应该把这两个字段都移走,然后被依赖的非主键字段在新表是主键,在原表是外键!

If a table is not in third normal form, remove the non-key fields that are dependent   on a field(s) that is not the primary key. Create another table with these fields and   the field that they do depend on.


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14377/viewspace-2677385/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-09-30

  • 博文量
    191
  • 访问量
    287586