You are on page 1of 26

1

Databases
Topic 5:
The Relational Model 1
Topic Review
Topic 3 – Entity Relationship Modelling 1

Topic 4 – Entity Relationship Modelling 2


Scope and Coverage

This topic will cover:


• Aims of the relational model

• Basic concepts of the relational model

• Terminology
4

Background to Relational Model


• Dominates the market in databases

• Second generation of DBMSs

• Developed by E.F. Codd in 1970

• In the relational model, all data is logically structured in relations.

• Relations can be thought of as tables.


5

Table

Do not confuse relations with


relationships in ER models

Entity A Entity B
6

History – Theoretical Basis


• E. F. Codd’s 1970 paper “A relational model of data for large shared data
banks”

- There should be a high degree of data independence.

- There should be a minimum of redundancy: relations should be


normalised.

- There should be a set-orientated data manipulation language.


7

Data Independence
• Changes in the internal data representation, such as file structure,
storage and access paths should not have an effect on the
applications programs.
8

Normalised Relations
• By having an underpinning in set theory, it is possible to
organise relations as sets so that there is a minimum of data
redundancy. This process is known as normalisation.
9

Terminology -1
1) Relation

2) Attribute

3) Domain

4) Null

5) Not Null
Attributes 2) Attribute = Column

1) Relation = Table Student ID First Name Last Name Course Address


Code
Relation

S334 Dave Watson COMP UK 4) Null


S765 Jagpal Jutley COMP
S783 Cynthia Kodogo HIST USA
S111 Wallace Antigone LIT

5) Not Null
3) Domain of valid course
codes:
COMP, HIST, LIT etc.
11

Terminology - 2
1) Tuple
2) Degree

3) Cardinality

4) Relational Database

5) Relational Schema
1) Tuple = Row Student ID First Name Last Name Course Code

Cardinality
4 Tuples S334 Dave Watson COMP
S765 Jagpal Jutley COMP
S783 Cynthia Kodogo HIST
S111 Walace Antigone LIT
3) Cardinality =
Number of
Degree tuples/rows

2) Degree = Number of attributes/columns

4) Relational Database = a database structured to recognize relations

5) Relational Schema = refers to the meta-data


13

Alternative Terminology
Formal Term Alternative 1 Alternative 2

Relation Table File

Tuple Row Record

Attribute Column Field


14

Properties of a Relation 1
Unique (3) Order (2) Cell Value (1)

• Relation/table name • Columns order is insignificance • Single value (atomic)

• Attribute/column name • Rows order is insignificance

Student Table
• Rows (no duplicate)
Student ID First Name Last Name Course Code

S334 Dave Watson COMP


S765 Jagpal Jutley COMP
S783 Cynthia Kodogo HIST
S111 Walace Antigone LIT
15

Properties of a Relation - 1
• It has a name which is unique within the relational schema.

• Each cell of a relation contains exactly one value.

• Each attribute has a name.

• Each tuple is unique.

• The order of attributes is insignificant.

• The order of tuples is insignificant.


16

Activity - Is This a Relation?


Student Name Modules Course

Guy Smith Med1 Medieval History 1 History

Med2 Medieval History 2

TCE Twentieth Century


Sarah Anusiem OS Operating Systems Computing
12 New Street
Lagos NET Networks
17

Properties of a Relation - 2
Student Name Modules Course • relation name - X

Guy Smith Med1 Medieval History


• attribute name – YES
History 1

Med2 Medieval • tuple is unique - YES


History 2

TCE Twentieth • order of attributes is insignificant – YES


Century
Sarah Anusiem OS Operating Computing • order of attributes is insignificant – YES
12 New Street Systems
Lagos
NET Networks • Cell value - X

This is not a relation


18

Now a Relation - Still Problems


Students
Student Name Address Modules Course

Guy Smith Med1 Medieval History 1 History

Guy Smith Med2 Medieval History 2 History

Guy Smith TCE Twentieth Century History

Sarah Anusiem 12 New Street OS Operating Systems Computing


Lagos
Sarah Anusiem 12 New Street NET Networks Computing
Lagos

1. Repeating Group → Student Name, 2. No Repeating Group → Module


Address, Course
19

Turned into a set of normalized relations


Students Modules
Student ID Name Address Course Module Code Name
Med1 Medieval History 1
28 Guy Smith History OS Operating Systems
Med2 Medieval History 2
23 Sarah 12 New Street Computing NET Networks
Anusiem Lagos
TCE Twentieth Century
History

1…* 1…*
Student Module

1 1…* StudentM 1…* 1


Student Module
odule
20

1 1…* StudentM 1…* 1


Student Module
odule
Primary Key
Students Modules
Primary Key
Student ID Name Address Course Module Code Name
Med1 Medieval History 1
28 Guy Smith History OS Operating Systems
Med2 Medieval History 2
23 Sarah 12 New Street Computing NET Networks
Anusiem Lagos
TCE Twentieth Century
History

Foreign Key Student Modules


Student ID Modules Code Foreign Key
28 Net

23 Med 1

28 OS

23 Med 2
21

Normalisation
• This process of moving from data that is not in a relational form, to a
relation, and finally to a set of ideal relations is known as
normalisation.

• We will be exploring normalisation more in the next session...


22

Keys
• Primary Key

• Foreign Key

• Super Key

• Candidate Key
23

Super Key

Primary Key Candidate Key


Foreign Key

EmpId EmpName EmpLicence EmpPassport DepID DepID Designation


1001 Matt LC1201 MA100LC 1 1 BPO
1002 Maxy LC2078 XY100LC2 2 2 Account
1003 Roy LK00928 LK100RO 3 3 IT

Employee Table Department


Primary Key Table
24

Learning Outcomes – Have We Met Them?

• By the end of this topic, students will be able to:


• Understand the aims of the relational model

• Understand the basic concepts of the relational model

• Define key terms of the relational model


25

References
• Connolly, T. & Begg, C. (2004). Database Systems: A Practical Approach to Design,
Implementation, and Management, 4th Edition. Addison Wesley. Chapter 3.
• Codd, E. F. (1970), “A Relational Model for Large Shared Data Banks”. Retrieved on
20/05/11 from: http://www.seas.upenn.edu/~zives/03f/cis550/codd.pdf
• McJones, P. (1995). Discussion of System R: “The 1995 SQL Reunion, People,
Projects and Politics”. Retrieved on 20/05/11 from:
http://www.mcjones.org/System_R/SQL_Reunion_95/

• Retrieved on 20/05/11 from:


http://www.mcjones.org/System_R/SQL_Reunion_95/
26

You might also like