Chapter 2
Chapter 2
Key constraints
Super Key: an attribute or set of attributes that uniquely identifies a
tuple within a relation.
Candidate Key: a super key such that no proper subset of that
collection is a Super Key within the relation.
A candidate key has two properties:
1. Uniqueness
2. Irreducibility
If a candidate key consists of more than one attribute it is called
composite key.
Primary Key: the candidate key that is selected to identify tuples
uniquely within the relation.
Foreign Key: an attribute, or set of attributes, within one relation that
matches the candidate key of some relation.
A foreign key is a link between different relations to create the view
or the unnamed relation Prepared by: Elsaye B. @WSU-DTC 12
Cont..
Referential constraints
A referential integrity constraint is also known as
foreign key constraint. A foreign key is a key whose
values are derived from the Primary key of another
table.
The table from which the values are derived is known as
Master or Referenced Table and the Table in which
values are inserted accordingly is known as Child or
Referencing Table,
In other words, we can say that the table containing the
foreign key is called the child table, and the table
containing the Primary key/candidate key is called the
referenced or parent table.
Prepared by: Elsaye B. @WSU-DTC 13
Cont..
There are three referential integrity constraint:
Insert Constraint: Value cannot be inserted in
CHILD Table if the value is not lying in
MASTER Table
Delete Constraint: Value cannot be deleted
from MASTER Table if the value is lying in
CHILD Table
UPDATE Constraint: Value cannot be
modified in CHILD Table if the value is not
lying in MASTER Table.
Prepared by: Elsaye B. @WSU-DTC 14