Week # 3
Week # 3
Week # 3
Systems
CHAPTER # 5
THE RELATIONAL DATA MODEL AND
RELATIONAL DATABASE CONSTRAINTS
Fizza.aqeel@nu.edu
Chapter Outlines
Degree of Relation?
Relation Definition
Using set theory
► A relation (or relation state) r(R) is a
mathematical relation of degree n on the
domains dom(A1), dom(A2), … , dom(An),
which is a subset of the Cartesian product
(denoted by ×) of the domains that define
► R: r(R) ⊆ (dom(A1) × dom(A2) × . . . × (dom(An))
► Cartesian product: All possible combinations
of values from the underlying domains.
► Total number of tuples in the Cartesian
product: |dom(A1)| × |dom(A2)| × . . . × |
dom(An)|
Relational Model
Concepts
► Relation State: The state of the whole database
will correspond to the states of all its relations
at a particular point in time.
Characteristics of Relations
Referential integrity 5- 23
constraint
► A constraint involving two relations
► The previous constraints involve a single
relation.
► Used to specify a relationship among tuples
in two relations:
► The referencing relation and the referenced
relation.
Referential Integrity
► Tuples in the referencing relation R1 have
attributes FK (called foreign key attributes)
that reference the primary key attributes PK of
the referenced relation R2.
► A tuple t1 in R1 is said to reference a tuple t2
in R2 if t1[FK] = t2[PK].
► A referential integrity constraint can be
displayed in a relational database schema as a
directed arc from R1.FK to R2.
Referential Integrity (or
foreign key) Constraint
► Statement of the constraint
► The value in the foreign key column (or
columns) FK of the referencing relation R1
can be either:
► (1) a value of an existing primary key value of a
corresponding primary key PK in the referenced
relation R2, or
► (2) a null.