Single attribute primary key and second normal form (2NF)

回眸只為那壹抹淺笑 提交于 2019-12-25 18:20:18

问题


I am not sure if this statement is true or false: "A table with a single attribute primary key is automatically in at least second normal form (2NF)."

I think it is TRUE but I cannot justify why.


回答1:


For a table to be in first normal form,an attribute of a table cannot have multiple values

For example ,

id   mobile_number   age
------------------------------
1    9xxx5xxxxx      25
     9xxx6xxxxx      
2    8xxxx5xxxx      26 
     7xxxx5xxxx      

This can be normalized to 1NF as follows,

id  mobile_number  age
------------------------------------
1   9xxx5xxxxx     25
1   9xxx6xxxxx     25
2   8xxxx5xxxx     26 
2   7xxxx5xxxx     26 

A table is said to be in second normal form if the table is in the first normal form and no non-prime attributes depend on a proper subset of any candidate key

Here candidate key is {id,mobile_number}

Non prime attribute is age

The table is not in 2NF because the non-prime attribute(age) is dependent on proper subset of candidate key(id) alone.

To normalize this to 2NF,we split the table as follows

id   mobile_number
------------------------------
1    9xxx5xxxxx
1    9xxx6xxxxx
2    8xxxx5xxxx
2    7xxxx5xxxx

id age
------
1  25
2  26  


来源:https://stackoverflow.com/questions/55589079/single-attribute-primary-key-and-second-normal-form-2nf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!