Lecture 4
Lecture 4
Lecture 4
▪ Include:
▪ domain constraints
▪ key constraints
▪ Superkey, key, candidate key, primary key, prime and nonprime attribute.
▪ Constraints on NULLs
▪ Entity integrity constraints
▪ Referential integrity constraints
domain constraints
▪ A must be an atomic value from the domain dom(A).
▪ key constraints
▪ Superkey:
▪ A superkey of a relation schema R = {A1, A2, … , An} is a set of
attributes S ⊆ R with the property that no two tuples t1 and t2 in any
legal relation state r of R will have t1[S] = t2[S].
▪ Every relation has at least one default superkey, the set of all its
attributes.
▪ key constraints
▪ Key:
▪ A key K is a superkey with the additional property that removal
of any attribute from K will cause K not to be a superkey
anymore.
▪ A key has to be minimal
▪ A key with multiple attributes must require all its attributes
together to have the uniqueness property.
▪ key constraints
▪ Candidate key:
▪ In general, a relation schema may have more than one key. In
this case, each of the keys is called a candidate key
▪ It is common to arbitrarily designate one of the candidate keys
as the primary key of the relation and the others are called
secondary keys.
▪ key constraints
▪ prime and nonprime attribute:
▪ An attribute of relation schema R is called a prime attribute of
R if it is a member of some candidate key of R.
▪ An attribute is called nonprime if it is not a member of any
candidate key.
▪ Constraints on NULLs
▪ specifies whether NULL values are or are not permitted.
▪ For example, if every STUDENT tuple must have a valid, non-NULL value
for the Name attribute.