Database Reference
In-Depth Information
Check
. Applies a condition to a column value where that value must
evaluate to TRUE and can be inline or out-of-line. A condition is of
the form
.
See Chapter 7 for details on comparison conditions and how to con-
struct conditions.
expression condition expression
,
such as
columnA = 5
Primary Key
. A primary key defines the column or set of columns
that uniquely identify each row in a table. The primary key can be
referenced by and validated against foreign keys in other tables (or
in a different column or set of columns in the same table). It can be
defined either inline (if it uses one column) or out-of-line (if it uses
one or more columns). Because a primary key uniquely identifies a
superset entity relationship, it must be unique. Therefore, a primary
key automatically contains a unique constraint. Additionally, a pri-
mary key cannot be a null value because null values are not
included in indexes. Indexes are covered in Chapter 21. Remember,
a primary key inherently has both a unique constraint and a NOT
NULL constraint.
Foreign Key
. A foreign key defines the relationship between the par-
ent (superset) table and the child (subset) table. The foreign key
resides in the child table. A foreign key must reference the primary
key (or a unique key) of the referenced table. A foreign key constraint
requires that the column value in the foreign key must be identical to
a primary key value in the referenced table. Like the primary and
unique key constraints, a foreign key can use one column or a set of
columns. A foreign key constraint must be defined out-of-line if it
contains more than a single column and can be either inline or out-
of-line if it uses a single column.
REF
. A REF constraint is a reference between an object and an
object type.
20.2
Managing Constraints
A constraint can be applied to an individual column in a table or, in some
cases, to a table as a whole. Constraints can even be used in views. An indi-
vidual column constraint is known as an inline constraint because it only
applies to that specific column. A table-level constraint is known as an out-
of-line constraint because it applies to the table as a whole.
So how do we create and maintain constraints? Constraints can be
applied and used in the CREATE TABLE, CREATE VIEW, ALTER
 
Search WWH ::




Custom Search