0% found this document useful (0 votes)
66 views5 pages

The Relational Model What's Wrong With Pre-Relational Databases?

The document discusses some of the fundamental problems with pre-relational, or navigational, databases and outlines some of the key objectives and concepts of the relational database model proposed by E.F. Codd in 1970. Specifically, it notes that access to data in navigational databases requires going through a root record, which can make queries inefficient. The relational model aims to overcome this and other shortcomings by developing a mathematical model of data management based on relations, attributes, and tuples. Some key concepts covered include relation schemas, domains, keys, null values, and relationships between relations.

Uploaded by

Kareem Nabil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views5 pages

The Relational Model What's Wrong With Pre-Relational Databases?

The document discusses some of the fundamental problems with pre-relational, or navigational, databases and outlines some of the key objectives and concepts of the relational database model proposed by E.F. Codd in 1970. Specifically, it notes that access to data in navigational databases requires going through a root record, which can make queries inefficient. The relational model aims to overcome this and other shortcomings by developing a mathematical model of data management based on relations, attributes, and tuples. Some key concepts covered include relation schemas, domains, keys, null values, and relationships between relations.

Uploaded by

Kareem Nabil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

What's wrong with pre-relational databases?

THE RELATIONAL MODEL


CUSTOMER
Name Address
INTRODUCTION
STRUCTURE
INTEGRITY
MANIPULATION ORDER
Order
VIEWS Number
Date
CONCLUSION

INVOICE ORDER_ITEM
References: Invoice Date Amount
Part number
No Quant

Connolly & Begg, Database Systems, Fourth Edition pp 70-87.


The fundamental problem of navigational data models is that access to data must be via
Fifth Edition pp 91 – 107. a root record. EG. Access to all ORDER records must be via CUSTOMER records. To
produce a list of all ORDERs, extract the first CUSTOMER, find and list the ORDER
records belonging to that customer, extract the next CUSTOMER etc.

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

In practice it is usually best to add a surrogate (an artificial key)


Candidate Keys: possible keys for a table (____________________)
Primary key: Film_id - Relation schema now written as:
FILM(Film_id, Title, Release_year)

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

ENTITY INTEGRITY CONSTRAINTS Film_id Title Release_year Dir_id


f1 Waterworld 1995 d1
f2 Land and Freedom 1995 d2
The primary key must not contain null values f3 The Big Sleep 1946 d3
f4 Today We Live 1933 d3
FILM
Film_id Title Release_year
f1 Waterworld 1995 A referential (integrity) constraint says that all
f2 Land and Freedom 1995 values which appear in the foreign key column
f3 The Big Sleep 1946
1933
must also appear in the corresponding primary
f4 Today We Live
null Citizen Kane 1941 key column

This structure is illegal! DIRECTOR

The basis for this is that: Name Dir_id


Kevin Reynolds d1
i) the primary key is the way in which the tuple is identified. Ken Loach d2
Howard Hawks d3
ii) If the primary key is null then this is the same as saying that the tuple Joel Schumacher d4
can not be identified.

Referential diagrams are a useful way of expressing referential constraints:


Manipulation

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

Natural join FILM


FILM Film_id
f1
Title
Waterworld
Release_year
1995
Dir_id
d1
Outer Joins
Film_id Title Release_year Dir_id Natural join combines f2 Land and Freedom 1995 d2
f1 Waterworld 1995 d1 1946
f2 Land and Freedom 1995 d2
related tuples from f3 The Big Sleep d3
Sometimes it is
f4 Today We Live 1933 d3
f3 The Big Sleep 1946 d3 two relations and f5 Jurassic Park 2 null null useful to keep
f4 Today We Live 1933 d3
f5 Jurassic Park 2 null null deletes the duplicated non-matching
column (Dir_id). It is DIRECTOR tuples.
DIRECTOR only possible where Name Dir_id
Kevin Reynolds d1
Name Dir_id the join attributes are Ken Loach d2 This possiblility is
Kevin Reynolds d1 identically named. Howard Hawks d3
Ken Loach d2 Joel Schumacher d4
provided for by
Howard Hawks d3 the OUTER JOIN.
Joel Schumacher d4 Join attributes need FILM_DIRECTOR FILM DIRECTOR
FILM_DIRECTOR FILM * DIRECTOR not be primary/foreign LEFT, RIGHT
keys. the symbol for a left AND FULL outer
outer join operation
the symbol for the FILM_DIRECTOR joins are all
natual join operation
Natural joins take possible.
FILM_DIRECTOR Film_id Title Release_year Dir_id Name
place on all common f1 Waterworld 1995 d1 Kevin Reynolds
Film_id Title Release_year Dir_id Name f2 Land and Freedom 1995 d2 Ken Loach
f1 Waterworld 1995 d1 Kevin Reynolds attributes in two The Big Sleep 1946 Howard Hawks
f3 d3
f2 Land and Freedom 1995 d2 Ken Loach relations. f4 Today We Live 1933 d3 Howard Hawks
f3 The Big Sleep 1946 d3 Howard Hawks f5 Jurassic Park 2 null null null
f4 Today We Live 1933 d3 Howard Hawks
base relation
FILM
Film_id Release_year Dir_id
VIEWS
Title
f1 Waterworld 1995 d1
f2 Land and Freedom 1995 d2 A View is an abstract of a
f3 The Big Sleep 1946 d3
f4 Today We Live 1933 d3 relation. CONCLUSION
f5 Jurassic Park 2 null null The relational model is a mathematical definition of a means of
It does not contain data but structuring and manipulating data.
in other respects behaves in Various implementations exist which address some features of the
the same way as a relation. relational model.
view Applications of relational databases are likely to be around for a long
Views help to simplify time.
OLD_FILMS
relational database
Title Release_year
structures for users and
system developers and can
also be used as a security
mechanism.
RESULT π (OLD_FILM)
Title

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

WHAT TUPLES DOES MYSTERY CONTAIN?


WHAT IS THE MEANING OF THE QUERY?
There is a problem with semantics in the relational model eg. the meaning of
EMPLOYEE.Extension is not stored explicitly within the model.

You might also like