The Relational Model What's Wrong With Pre-Relational Databases?
The Relational Model What's Wrong With Pre-Relational Databases?
INVOICE ORDER_ITEM
References: Invoice Date Amount
Part number
No Quant
RELATION SCHEMA
OR INTENSION
OBJECTIVES OF THE RELATIONAL MODEL
FILM(Title,Release_year)
E.F.Codd. "A relational model of data for large shared data banks",
Communications of the ACM 13, No6 (June 1970).
RELATION NAME ATTRIBUTE
(TABLE NAME) (COLUMN) DEGREE = 2
existing database models/systems: CARDINALITY = 4
RELATION INSTANCE
needless complexity. OR EXTENSION
difficult to understand, maintain, use. The important point
large budget & support staff. FILM concerning the mathematical
access required prior preparation by system staff. Title Release_year basis is that a relation is a
Waterworld 1995
limited query-only capabilities. Land and Freedom 1995 TUPLE set of tuples
The Big Sleep 1946 (ROW)
no logical independence. Today We Live 1933
objectives were:
to overcome existing shortcomings.
DOMAIN - Film_Titles- the pool
develop a mathematical model for database management of all possible values from which
values in the Titles column may be
drawn
KEYS AND SUPERKEYS
NULLS A key is a guaranteed way of addressing a tuple
A null is a special marker which means that the value of an attribute is Title Release_year
Waterworld 1995
either unknown or does not apply. Land and Freedom 1995
Null is different from zero or blank. The Big Sleep 1946
Today We Live 1933
May be necessary to prevent a column from containing nulls.
Superkey: an attribute/combination of attributes for which no two tuples have the
same value. (Title, Title+Release_year)
Key: a minimal superkey (______________)
Title Release_year
Waterworld 1995 Film_id Title Release_year
Land and Freedom 1995 f1 Waterworld 1995
The Big Sleep 1946 f2 Land and Freedom 1995
Today We Live 1933 f3 The Big Sleep 1946
Jurassic Park 2 null f4 Today We Live 1933
The Lion King null
NURSE
Relationships NURSE NUMBER NAME WARD_NO SUPERVISOR
Foreign key 963456 DIEP SEI PIN W1 NULL
965664 MURRAY JEAN ANN W1 963456
FILM WARD
The posting of the foreign Film_id Title Release_year Dir_id WARD_NO TYPE NAME
f1 Waterworld 1995 d1
key implies the existence f2 Land and Freedom 1995 d2
W1 MATERNITY SIMPSON
f3 The Big Sleep 1946 d3
of the relationship. f4 Today We Live 1933 d3
W2 GENERAL LISTER
W3 SURGERY PASTEUR
How many instances of A relationship between two entities WHAT IS/ARE THE :
DIRECTOR are related to is expressed by posting the primary
NAMES OF THE RELATIONS? NAMES OF THE ATTRIBUTES?
key as a foreign key.
key
each instance of FILM? DOMAINS? CANDIDATE KEYS?
How many instances of SUPERKEYS? PRIMARY KEYS?
DIRECTOR FOREIGN KEYS? DEGREE?
FILM are related to each
Name Dir_id CARDINALITY? TUPLES?
instance of DIRECTOR? Kevin Reynolds d1
Ken Loach d2
Howard Hawks d3 HOW MANY NURSES ARE ASSIGNED TO EACH WARD?
The relationship is 1:N Joel Schumacher d4
(one-to-many) HOW MANY WARDS DOES EACH NURSE WORK IN?
HOW DO YOU KNOW?
REFERENTIAL CONSTRAINTS
FILM
DIRECTOR FILM
Manipulation in the relational model is by a set of operators known as
relational algebra.
Foreign key rules govern actions taken in response to an attempt to put There are a number of operators available but three (RESTRICT, PROJECT and
the database in an illegal state: eg DELETE may be either PREVENTED JOIN) are of particular interest.
or CASCADED
RESTRICT Project
FILM FILM
Film_id Title Release_year Dir_id Film_id Title Release_year Dir_id
f1 Waterworld 1995 d1 f1 Waterworld 1995 d1
f2 Land and Freedom 1995 d2 f2 Land and Freedom 1995 d2
The Big Sleep 1946 d3 f3 The Big Sleep 1946 d3
f3
Today We Live 1933 d3 f4 Today We Live 1933 d3
f4
Jurassic Park 2 null null f5 Jurassic Park 2 null null
f5
RESTRICT
this is a restriction (or SELECT) this is the
attribute list
condition gives a PROJECT
horizontal gives a
RECENT_FILMS σ (FILM) 'slice' of a RESULT π (FILM)
Release_year > 1990
Title, Release_year vertical
relation. π is the 'slice' of a
σ is the symbol for
symbol for relation
PROJECT
restrict
RESULT
Title Release_year
RECENT_FILMS Waterworld 1995
Film_id Title Release_year Dir_id Land and Freedom 1995
f1 Waterworld 1995 d1 The Big Sleep 1946
f2 Land and Freedom 1995 d2 Today We Live 1933
Jurassic Park 2 null
PHONE CALL
Extension Phone_number Duration
3212 01232 543218 8
3212 01987 342154 5
4325 01987 342154 10
4325 0141 665 7654 6
4325 01232 543218 6
EMPLOYEE
Employee_id Employee_name Address Phone_number Extension
4325 Jill Graham Green Street 01987 342154 3212
7865 Bill Brown The Moor 0141 665 7654 4325
9856 Ann Lee Codd Row 01562 234322 5432
MYSTERY π (σ (PHONE_CALL * EMPLOYEE))
Employee_name Duration > 5