Database Reference
In-Depth Information
20
Constraints
In this chapter:
What is Referential Integrity?
What are constraints and how are they used to implement Referential
Integrity?
How are constraints placed into tables?
What else can constraints do?
This chapter shows you how to define constraints on tables. Constraints
perform validation on data both within and between tables and, to a lesser
degree, with views.
Primary and foreign key constraints are probably the most significant of
constraints. These constraints can be used to enforce the validity (integrity)
of relationships (references) between rows in tables (entities). A primary key
reference is placed on a unique identifying column in a superset entity. A
foreign key is placed on a subset table, which contains a copy of the primary
key value from the superset entity. Oracle uses primary and foreign key con-
straints to validate values between superset and subset tables. Referential
Integrity can be enforced using constraints or triggers, or can be coded at
the application level. My personal recommendation is to use constraints.
Note:
A superset contains a subset. The superset contains a primary key and
the subset contains a foreign key. A foreign key can have many iterations of
a primary key.
So let's move on to looking at constraints in detail.
Search WWH ::




Custom Search