Relational Model
The relational model is based on the mathematical concept of a relation, which is
physically represented as a table. A table is a matrix of a series of row and column
intersections. Codd, a trained mathematician, used terminology taken from
mathematics, principally set theory and predicate logic. In this section, the
terminology and structural concepts of the relational model will be explained.
Data Structure of Relational Database
Following are the basic data structures used in relational database model.
i. Relation: A relation is a table with columns and rows. It consists of all possible
tuples.
ii. Tuple: Single row of any relation is known as tuple.
iii. Attributes: These are the characteristics of any relation.
iv. Domain: Domain is the set of all permitted values or information about any
attributes.
v. Tuple variable: Tuple variable is the part of tuple or row, which is information
or data stored in relation for any attribute.
vi. Degree: Number of columns in any relation is known as its degree.
vii. Cardinality: Number of rows in any relation is known as its cardinality.
Fig 1: Basic data structures of relational database
Integrity Constraints
These are the rules or constraints applied to the database to keep data stable, accurate
or consistent. To keep database consistent, we have to follow some rules known as
integrity rules or integrity constraints.
a) Entity Integrity Rule (Integrity Rule 1)
Primary key or a part of it in any relation cannot be null. Suppose A is an attribute in
relation R which is taken as primary key then A must not be null.
b) Referential Integrity Rule (Integrity Rule 2)
A foreign key can be either null or it can have only those values which are present in
the primary key with which it is related. Suppose A is an attribute in relation R1, which
is also the primary key in relation R2, then value of A in R1 should either be null or
same as in relation R2.
Fig 2: Referential Integrity
c) Domain Constraints
The restrictions applied on domain are known as domain constraints. These
restrictions are applied to every value of attribute. By following these constraints, the
database is kept consistent. These restrictions include data types (integer, varchar,
char, time format, date format etc.), size of variable, checks (like value not null etc.)
etc.
Example. create table employee (Eid char (4), Name char (20),
Age integer (2), Salary integer,
primary key (Eid), Check (age>18))
Fig 3: Domain Constraints
d) Key Constraints
In any relation R, if attribute A is primary key then A must have unique value or you
can say that primary key attribute must have unique value. Duplicate values in
primary key are invalid.
Fig 4: Key Constraints
e) Tuple Uniqueness Constraints
In any relation R, all tuples in relation R must have distinct values. In other words,
Duplicate tuples within a single relation are not allowed.
Fig 5: Tuple Uniqueness Constraints