Database normalization
Superkey,Minimal key,Primary key和Candidate key
A superkey is a nonempty subset X of relational schema R = (A1 , … , An ) such that for any two rows t1 , t 2in a relational table created over a relational schema R t 1[X] ≠ t2 [X]
简而言之,如果X是R的一个超键,那么X→ A1 , … , An.
A minimal key is a superkey K with an additional property such that removal of any attribute from K will cause K not to be a superkey
最小键是超键的子集,它比起超键有一个附加条件就是如果在超键中删除任何一个属性就会导致它不再是超键。
例如,一个关系模式:DRIVER(licence#, employee#, first-name, last-name)
有两个最小键(licence#) and (employee#)
但是它可以有很多个超键:
(licence#) ,(employee#) , (licence#, employee#) , (licence#, first-name), (licence#, last-name) , (licence#, first-name, last-name)等等。
A primary key is an arbitrarily selected minimal key.
A candidate key is any other minimal key which is not a primary key.
举例:
DRIVER(licence#, employee#, first-name, last-name)
has a primary key (licence#) and a candidate key (employee#) 或者反过来也成立。
函数依赖项和键
如果函数依赖 licence#, employee# → first-name, last-nam在关系模式中有效
DRIVER(licence#, employee#, first-name, last-nam