Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

Relational Database Systems

Relational Model 1
STUDENTS Relation Name

RegNo Name DOR Prog Yr


Heading

P567 Kamau 02/05/99 BSc 3

Relation T123 Onyango 23/04/00 BSc (CS) 3

J777 Mwaniki 02/06/00 BComm 1


Body

P900 Rono 23/04/00 BSc 4

T877 Otieno 04/04/98 BSc(CS) 3

Relational Model 2
Relational Data Structures
 Relation is a table with columns and rows.
 Attribute is a column
 Domain is allowable values for one or more attributes
 Tuple is a row
 Degree - degree of a relation is the number of attributes
of contains.
 Cardinality – cardinality of a relation is the number of
tuples it contains
 Heading - consists of a fixed set of attributes
 Body - consists of a time‑varying set of tuples
Relational Model 3
Relational Data Structures
Properties of Relations
 The relation has a distinct name
 Each attribute has a distinct name
 Each cell of the relation contains one atomic value
 The values of an attribute are from the same domain
 The order of attributes has no significance
 No duplicate rows
 The order of rows has no significance (theoretically)

Relational Model 4
Relational Data Structures
Relational Keys
 Candidate Key - a set of unique identifiers
 Primary Key ‑ The candidate key selected to be the
primary key
 Composite Key - a candidate key that consists of two or
more attributes
 Foreign Key - A foreign key is an attribute(s) in one
relation whose values are required to match those of the
primary key of some relation

Relational Model 5
Relational Data Integrity
 Entity Integrity - No attribute participating in the
primary key of a relation is allowed to accept null values

 Referential Integrity - If a FK exist in a relation either


the foreign FK value must match a candidate key value in
a home relation or FK value must be wholly null.

 Null – represents a value for an attribute that is currently


unknown or is not applicable for this tuple

Relational Model 6
Relational Data Integrity
 Enterprise Constraints – Additional rules specified by
the users or DBA
 Domain Constraints – restriction on the values allowed
for attributes

Relational Model 7
Relational Data Languages
 The Data Manipulation Languages (DML) of relational
databases is based on Relational Algebra. Each operator of
the relational algebra takes either one or two relations as
its input and produces a new relation as its output

Relational Model 8
Relational Algebra
 SELECT - Extracts specified tuples (rows/records) from a
specified relation
 PROJECT - Extracts specified attributes (columns/fields)
from a specified relation
 JOIN - Produces a relation from two specified relations
consisting of all possible concatenated pairs of tuples, one
from each of the two specified relations, such that in each
pair the two tuples satisfy some specified condition

Relational Model 9
Relational Algebra
 DIVIDE - Takes two relations, one binary and one unary,
and builds a relation consisting of all values of one
attribute of the binary relation that match (in the other
attribute) all values in the unary relation
 UNION - Produces a relation consisting of all tuples
appearing in either or both of two specified relations
 INTERSECTION - Produces a relation consisting of all
tuples appearing in both of two specified relations

Relational Model 10
Relational Algebra
 DIFFERENCE - Produces a relation consisting of all tuples
appearing in the first and not in the second of two
specified relations
 PRODUCT-Produces a relation from two specified
relations consisting of all possible concatenated pairs of
tuples, one from each of the two specified relations

Relational Model 11

You might also like