Beruflich Dokumente
Kultur Dokumente
Databases
2014/15
Week 1 (Wednesday)
Initial Orientation
Shereen Fouad
Teaching Fellow in School of Computer Science
Overview
Motivation
What is a database.
Applications of database technology.
Initial orientation about the course.
2
Motivation
Consider a supermarket business.
What do you want to keep track of?
What is the size of the data?
How can the business:
store and manage such data?
retrieve, manipulate and disseminate data?
take critical business decision?
How can we monitor the performance of the business?
What is a Database?
The broad interpretation of a Database =
A collection of logically
coherent interrelated
data (raw facts of
interest to the end user)
Description of data
characteristics and
relationships
(Metadata: data about
data)
Teaching Staff
10
Application
Development
Database design
SQL
Database Internal
11
13
15
Course Text
C. Coronel, S. Morris, P. Rob & K. Crockett,
Database Principles: Fundamentals of Design, Implementation and
Management, 2nd Ed or 10th Edition, 2013.
CHAPTERS you need are published on the module website.
You can find the book in the Cs and University library.
16
Exercises
Every week I will give you some exercises to do in the lab session.
You need to submit the exercise electronically via canvas.
The ones up to and including Week 8 will be UNASSESSED.
You will get feedback from demonstrators via canvas.
The ones in Week 9 will be ASSESSED and will be due to submission in
week 11, accounting for 10% of the module mark.
Late submission on assessed exercise will lead to penalties.
17
Grading
Your final grade will be based on:
ONE CLASS TEST,
in week 8, Friday 21/11/2014 in the lecture hall (LT1 LAW)
accounting for 10% of the module mark.
Final Examination,
accounting for 80% of the module mark.
18
20
Summary
Database technologies are all over the place.
Database is a collection of logically coherent interrelated data as well
as a description of this data.
Information is the result of processing data to reveal its meaning
21
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 2 (Friday)
Introduction to Tables
Shereen Fouad
Teaching Fellow
Overview
Table Structure Example
Cross-references between places in a data repository (Referential
integrity)
STUDENT ID
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
37
42 George
St.
Finance
Building b1
E12367
Kent
Danial
42
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
21
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
60
45 Lime St.
24
CS
Building c2
E54344
Lea
John
34
6 Dan St.
Finance
Building b1
STUDENT
STUDENT ID
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
37
42 George
St.
Finance
Building b1
E12367
Kent
Danial
42
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
21
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
60
45 Lime St.
24
CS
Building c2
E54344
Lea
John
34
6 Dan St.
Finance
Building b1
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
37
42 George
St.
Finance
Building b1
E12367
Kent
Danial
42
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
21
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
60
45 Lime St.
24
CS
Building c2
E54344
Lea
John
34
6 Dan St.
Finance
Building b1
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
37
42 George
St.
Finance
Building b1
E12367
Kent
Danial
42
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
21
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
60
45 Lime St.
24
CS
Building c2
E54344
Lea
John
34
6 Dan St.
Finance
Building b1
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10nd Ed.
STUDENT
STUDENT ID
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
37
42 George
St.
Finance
Building b1
E12367
Kent
Danial
42
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
21
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
60
45 Lime St.
24
CS
Building c2
E54344
Lea
John
34
6 Dan St.
Finance
Building b1
STUDENT
STUDENT ID
F NAME
L NAME
AGE
STUDENT
ADDRESS
COURSE
NO.
COURSE
NAME
DEPARTMENT
LOCATION
E12345
John
Chopples
15
42 George
St.
Finance
Building b1
E12367
Kent
Danial
18
56 Malcom
St.
24
CS
Building c2
E54321
Michal
Blurp
19
5 Bristol St.
12
Marketing
Building b2
E5099
Amber
Rumpel
22
45 Lime St.
24
CS
Building c2
E54344
Lea
John
32
6 Dan St.
Finance
Building b1
COURSE
NO.
Chopples 15
42 George
St.
Kent
Danial
18
56 Malcom
St.
24
E54321
Michal
Blurp
19
5 Bristol St.
12
E5099
Amber
Rumpel
22
45 Lime St.
24
E54344
Lea
John
32
6 Dan St.
STUDEN
T ID
F
NAME
L
NAME
E12345
John
E12367
AGE
COURSE
COURSE NO.
COURSE
NAME
COURSE
LOCATION
Finance
Building b1
24
CS
Building c2
12
Marketing
Building b2
Referential Integrity
Referential integrity is relevant when one place in a data repository
needs to refer to something in another place: cross-references.
Referential integrity is achieved when every such referring place
contains a successful reference to another place or place-occupant
(or no reference at all).
Successful there just means that the reference succeeds in
specifying some other place(-occupant).
Associative Linking
The notion of relational database rests heavily on associative
linking.
Notice that associative linkages between different places constitute a
specialized sort of needed redundancy.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
COURSE
NO.
Chopples 15
42 George
St.
Finance
Danial
56 Malcom
St.
CS
5 Bristol St.
Marketing
STUDEN
T ID
F
NAME
L
NAME
E12345
John
E12367
Kent
E54321
Michal
Blurp
AGE
18
19
E5099
Amber
Rumpel
22
45 Lime St.
CS
E54344
Lea
John
32
6 Dan St.
Finance
COURSE
COURSE
NAME
COURSE
LOCATION
Finance
Building b1
CS
Building c2
Marketing
Building b2
(A) a criteria.
(B) a relation.
(C) a tuple.
(D) an attribute.
Specifying the location of a particular information in a book, e.g. by page and line number, is
considered as
(A) associative linking .
(B) pointing .
(C) degree.
(D) tuple.
(B) degree
(B) attribute
(D) relation
(B) a tuple
(B) an attribute
(D) a relation
ADDRESS
PHONES
BIRTHDAY
Babloop Porkypasta
0121-944-5677
07979-888777
11 January 1969
Coriolanus
Zebedee
OCrackpotham
The Wellyboots,
Boring-under-Mosswood,
Berks, HP11 1XX
016789-997710
Johnny
H: 020-7111-2222
W: 020-7111-2255
M: 07887-842657
Harborne
???
Oct 05
ex-dir
16 Sep?
(refused to tell me
how old she was)
Rows are uniquely determined (picked out) by the values in some set
of columns (possibly the whole set, but could be fewer).
That is, if you imagine some values for those columns, there is at
most one row that has exactly those values in those columns.
LAST Name
FIRST
Name
MI
ADDRESS
Home
Phone
Mobile
B year
B day
Porkypasta
Babloop
0121-9445677
07979888777
1969
Jan 11
OCrackpotham
Coriolanus
The Wellyboots,
Boring-underMosswood,
Berks, HP11
1XX
016-789997710
1999
May 20
Delfino
Johnny
Next to the
Tescos in Upper
Street
020-71112222
1957
June 1
Clinton
Hilary
0121-9545646
1997
Sep 16
07887842657
Summary
Database design defines the database structure
DBMS enforces data integrity and eliminates redundancy
Relational database rests heavily on associative linking rather than
pointing
DBMS imposes some restrictions Database Tables
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 2 (Wednesday)
Introduction to Database and Database Management System
Shereen Fouad
Teaching Fellow in School of Computer Science
Overview
More about Databases.
Database Management Systems.
Database Systems.
Types of Databases.
Problems with File System Data Management
Types of Databases
Databases can be classified according to various aspects, for
example:
1. Number of users
Single-user database: supports only one user at a time
Desktop database
Multi-user database: supports multiple users at the same time
Workgroup database
Enterprise database
2. Database location(s)
Centralized database: data located at a single site
Distributed database: data distributed across several different sites
6
client
Database
Database
Database
client
client
client
client
Database
7
Languages DBMS
The Data Definition Language (DDL)
used by Database Administrator (DBA)
used to describe/create external and logical schema
10
Database System
Organization of components
that control the collection,
storage, management and
use of data.
Five major parts of a database
system:
Hardware
Software
People
Procedures
Data
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10nd Ed.
11
(B) Table
(C) Attributes
(D) Switchboards
12
Files
Academic
Student ID
Student Name
Courses
Finance
Student ID
Student Name
Student fees
Student
Services
Student ID
Student Name
Accommodation No.
13
Redundancy implies that if you want to modify/delete a student name, you need to:
know whether there is replication, or check for possible replications
go to the effort of repeating changes when the student name is replicated
avoid errors in such repeated changes.
Files
Academic
Student ID
Student Name
Courses
Finance
Student ID
Student Name
Student fees
Student
Services
Student ID
Student Name
Accommodation No.
15
Other problems
Poor design and lack of standardized data modeling
17
Alternative solution:
Database System Application
Departments
Academic
Finance
Student
Services
DBMS
Database
Data
Metadata
18
19
20
21
(A) DML
(B) DDL
(C) VDL
(D) SDL
22
Summary
Data are usually stored in a database.
Databases can be classified to different types according to various
aspects.
DBMS implements a database and manages its contents
Database systems is the combination of database and DBMS.
File System Data Management suffers from several limitations when
compared to Database Systems.
23
Announcement
Week 2 exercise is now available on the module canvas website (Nontechnical) and (non - assessed)
Hand in Electronic copy via canvas (submission is optional if you are
seeking feedback)
Hand-out for getting started with PostgreSQL is now available on canvas
Lab sessions are starting this week (Thursday from 2pm to 5 pm in LG04)
Documents is now available on the module canvas website
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 3 (Friday)
Advanced SQL
Shereen Fouad
Teaching Fellow
RENAMING ATTRIBUTES
SELECT DISTINCT SALARY AS "MONTHLY PAYMENT" FROM EMPLOYEE;
COMPUTED ATTRIBUTES
SELECT FNAME, SALARY, DNO FROM EMPLOYEE ORDER BY DNO ASC, SALARY DESC
CHECKING FOR NULLS
SELECT FNAME, LNAME FROM EMPLOYEE WHERE SUPER_SSN IS NULL;
BETWEEN
SELECT * FROM EMPLOYEE WHERE (SALARY BETWEEN 30000 AND 40000) ;
Overview
Aggregate Functions
GROUP BY and Having
Nested Query
Any and ALL
EXIST and NOT EXIST
Aggregate Functions
Summary information can easily be extracted from a table using one of the
operators COUNT, MAX, MIN, AVG, SUM,STDEV
Example:
Find the sum of the salaries of all employees, the maximum salary, the
minimum salary, and the average salary.
SELECT SUM (Salary), MAX (Salary), MIN (Salary), AVG (Salary)
FROM EMPLOYEE;
GROUP BY
Allows for categorical output.
Apply aggregate operators to each of several groups of tuples.
First select these rows
Syntax:
SELECT
FROM
[WHERE
[GROUP BY
[HAVING
columnlist
tablelist
conditionlist]
columnlist]
conditionlist];
GROUP BY
For each department, retrieve the department number, the number
of employees in the department, and their average salary.
SELECT Dno, COUNT (*), AVG (Salary)
FROM EMPLOYEE
GROUP BY Dno;
STUDENT
STUDENT
ADDRESS
COURSE
NO.
Chopples 24
42 George St.
Kent
Danial
16
56 Malcom
St.
24
E54321
Michal
Blurp
21
5 Bristol St.
12
E5099
Amber
Rumpel
25
45 Lime St.
24
E54344
Lea
John
20
6 Dan St.
STUDEN
T ID
F
NAME
L
NAME
E12345
John
E12367
AGE
STUDENT
STUDEN
T ID
FNAME LNAME
AGE
STUDENT
ADDRESS
COURSE
_NO.
E12345
John
Chopples
24
42 George St.
E12367
Kent
Danial
16
56 Malcom St.
24
E54321
Michal
Blurp
21
5 Bristol St.
12
E5099
Amber
Rumpel
25
45 Lime St.
24
E54344
Lea
John
20
6 Dan St.
L_NAME
PHONE
EMPL. ID
AGE
SALARY
John
Chopples
0121-414-3816
E22561
37
23,000
Alex
Blurp
01600-719975
E85704
21
21,000
Anbreen
Rumpel
07970-852657
E22561
88
40,000
AGE
John
88
Alex
88
Anbreen
88
In Nested Queries the WHERE clause can itself contain a SQL query!
Also FROM and HAVING clauses can too
The above subquery returns a single value
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
PHONE_
ID
PHONE
TYPE
STATUS
798687
John
Chopples
E22561
37
0121-414-3816
office
OK
668768
Alex
Blurp
E85704
21
01600-719975
home
FAULT
978098
Anbreen
Rumpel
E22561
70
0121-440-5677
home
OK
07970-852657
mobile
UNPAID
Result
F_NAME
L_NAME
John
Chopples
Alex
Blurp
Anbreen
Rumpel
Find the first and last names of employees who dont have a registered phone numbers.
SELECT F_NAME, L_NAME
FROM EMPLOYEE
WHERE PHONE_ID NOT IN
(SELECT PHONE
FROM PHONE_NUMBERS);
Result
NULL
ALL
List the names of employees whose salary is greater than the salary of
all the employees in department 4:
SELECT Lname, Fname
FROM EMPLOYEE
WHERE Salary > ALL
( SELECT Salary
FROM EMPLOYEE
WHERE Dno=4 );
Source of Image: Fundamentals of Database Systems (6th Edition) by Ramez Elmasri and Shamkant B. Navathe
ANY
Find the names of employees who earn more than someone else.
SELECT Lname, Fname
FROM EMPLOYEE
WHERE Salary > ANY
( SELECT Salary
FROM EMPLOYEE);
Source of Image: Fundamentals of Database Systems (6th Edition) by Ramez Elmasri and Shamkant B. Navathe
SELECT <columns>
FROM <tables>
WHERE NOT EXISTS <set>
Source of Image: Fundamentals of Database Systems (6th Edition) by Ramez Elmasri and Shamkant B. Navathe
References
Some of the SQL Examples presented in this lecture have been
obtained from the following text book:
Fundamentals of Database Systems (6th Edition)
by Ramez Elmasri and Shamkant B. Navathe
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 3 (Wednesday)
Introduction to SQL
Shereen Fouad
Teaching Fellow
Remember:
Associative Linking
This is how the tables are linked.
F_NAME
L_NAME
PHONE_ID
EMPLOYER_
ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
70
PHONE_
ID
PHONE
TYPE
STATUS
0121-414-3816
office
OK
01600-719975
home
FAULT
0121-440-5677
home
OK
07970-852657
mobile
UNPAID
EMPLOYER_ID
EMPLOYER
ADDRESS
NUM. EMPLS
SECTOR
E48693
BT
BT House, London,
1,234,5678
Private TCOM
E85704
Monmouth
School for Girls
Hereford Rd,
Monmouth,
245
Private 2E
E22561
University of
Birmingham
4023
Public HE
Overview
The main Categories SQL commands
The basic DDL and MDL commands
How to use SQL to query a database for useful information
UPDATE
Updating values in an individual cell (column specified by name; but how identify the row?)
SELECT
Retrieving values from an individual cell; doing calculations on them
Retrieving the values in the cells in some or all columns for some or all rows
Calculating statistics concerning values in particular columns across all rows, a subset of rows,
or several subsets of rows (count, max, min, average, standard deviation, )
Ordering rows in different ways in displays of a table.
COMMIT
Save a database transaction.
ROLLBACK
Rollback a database transaction.
Example Database
EMPLOYEE
PHONE_NUMBERS
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
978098
Alex
Anbreen
EMPLOYER
Blurp
Rumpel
4
2
E85704
E22561
21
70
PHONE_
ID
PHONE
TYPE
STATUS
0121-414-3816
office
OK
01600-719975
home
FAULT
0121-440-5677
home
OK
07970-852657
mobile
UNPAID
EMPLOYER_ID
EMPLOYER
ADDRESS
NUM. EMPLS
SECTOR
E48693
BT
BT House, London.
1,234,5678
Private TCOM
E85704
Monmouth
School for Girls
Hereford Rd,
Monmouth.
245
Private 2E
E22561
University of
Birmingham
4023
Public HE
SELECT Queries
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
88
SELECT
Used to list contents of table
Syntax:
SELECT column_list
FROM table_name;
or
SELECT *
FROM EMPLOYEE E
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
88
Result
3
Result
STATUS
OK
FAULT
UNPAID
PHONE
TYPE
STATUS
0121-414-3816
office
OK
01600-719975
home
FAULT
0121-440-5677
home
OK
07970-852657
mobile
UNPAID
Ordering a Listing
ORDER BY clause is used when listing order is important
ORDER BY clause
Example:
SELECT *
FROM EMPLOYEE
ORDER BY AGE DESC;
Result
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
SALARY
Anbreen
Rumpel
E22561
70
40,000
John
Chopples
E22561
37
23,000
Alex
Blurp
E85704
21
21,000
SELECT Queries
Fine-tune SELECT command by adding restrictions to search
criteria using:
Conditional restrictions
e.g. ,,, , etc.
Arithmetic operators
e.g. power operations, multiplications, divisions, additions and
subtractions
Logical operators
Searching data involves multiple conditions
e.g. AND, OR and NOT
Special operators
e.g. BETWEEN, IS NULL, LIKE, IN and EXIST
Conditional Restrictions
Add conditional restrictions to SELECT statement, using WHERE clause
Syntax:
SELECT columnlist
FROM tablelist
[ WHERE conditionlist ] ;
Conditional Restrictions
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
70
SELECT *
FROM EMPLOYEE E
WHERE E.AGE=70;
or
Result
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID AGE
SALARY
978098
Anbreen
Rumpel
E22561
978098
70
or
Result
F_NAME
L_NAME
PHONE_ID
Anbreen
Rumpel
Result
As keyword is used to put Aliases
(rename columns) in the result set
FIRST NAME
LAST NAME
PHONE_ID
Anbreen
Rumpel
Arithmetic Operators
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
SALARY
798687
John
Chopples
E22561
37
25000
668768
Alex
Blurp
E85704
21
21000
978098
Anbreen
Rumpel
E22561
70
50000
Source of Image: Database Principles: Fundamentals of
Design, Implementation and Management, 2nd Ed.
NEW AGE
Blurp
16
SELECT P.PHONE,P.TYPE
FROM PHONE_NUMBERS P
WHERE P.TYPE=office AND P.STATUS=OK;
Result
PHONE
TYPE
0121-414-3816
office
PHONE
TYPE
STATUS
0121-414-3816
office
OK
01600-719975
home
FAULT
0121-440-5677
home
OK
07970-852657
mobile
UNPAID
(C) a SQL query will not work if there are no indexes on the relations
(D) None of these
AS clause is used in SQL for
Which of the following operation is used if we are interested in only certain columns of a table?
(A) PROJECTION
(B) SELECTION
(C) UNION
(D) JOIN
A file manipulation command that extracts some of the records from a file is called
(A) SELECT
(B) PROJECT
(C) JOIN
(D) PRODUCT
Special Operators
BETWEEN: checks whether attribute value is within a range
LIKE: checks whether attribute value matches given string pattern
IS NULL: checks whether attribute value is null
IN: checks whether attribute value matches any value within a value list
EXISTS: checks if subquery returns any rows
BETWEEN
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
70
SELECT *
FROM EMPLOYEE
WHERE AGE BETWEEN 20 AND 40;
Result
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
LIKE
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
AGE
798687
John
Chopples
E22561
37
668768
Alex
Blurp
E85704
21
978098
Anbreen
Rumpel
E22561
70
SELECT F_NAME,L_NAME,AGE
FROM EMPLOYEE
WHERE F_NAME LIKE A%;
.%. is a wildcard for any substring (including the empty substring).
Result
F_NAME
L_NAME
AGE
Alex
Blurp
21
Anbreen
Rumpel
70
IS NULL
EMPLOYEE
Empl_ID
F_NAME
L_NAME
PHONE_ID
EMPLOYER_ID
SALARY
AGE
798687
John
Chopples
E22561
20000
37
668768
Alex
Blurp
E85704
978098
Anbreen
Rumpel
E22561
Blurp
21
25000
70
Special Operators
BETWEEN: checks whether attribute value is within a range
LIKE: checks whether attribute value matches given string pattern
IS NULL: checks whether attribute value is null
IN: checks whether attribute value matches any value within a value list
EXISTS: checks if subquery returns any rows
Summary
SQL commands can be divided into two overall categories:
Data definition language commands
Data manipulation language commands
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 4 (Friday)
Relational Model, Keys and Integrity Rules
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Overview
What business rules are and how they influence database design
The Evolution of Data Models
The relational database model offers a logical view of data
Database Keys
Superkey
Candidate key
Primary key
Foreign key
Business Rules
DB designer gains the main information about the organization which is considered
as the main blocks of building a data model.
Business Rules allow designer to:
understand the nature, role, and scope of data
understand business processes
develop appropriate relationship participation rules and constraints
Translating Business Rules into Data Model
Nouns translate into entities
Verbs into relationships among entities
Identify the relationship type and connectivity
The translation step should consider a comprehensive and unique object names.
The Development
of Data Models
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Relational Model
Implemented through the Relational
Data Management System (RDBMS)
Relational database model offers a
logical view of data.
Hides complexity represented in
hierarchal and network models from
the user
Entity is mapped to a relational table
Relational table stores collection of
related entities
Attributes is mapped to a column
table
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10nd Ed.
Keys
Each row in a table must be uniquely identifiable by a key
A superkey for a table is a collection of one or more attributes that determines all
the other attributes in the table, i.e. determines a whole row.
Trivially, the collection of all the attributes is a superkey.
A set of attributes in a relation is called a candidate key if, and only if,
Every tuple has a unique value for the set of attributes (uniqueness)
No proper subset of the set has the uniqueness property (minimality)
To determine what is a candidate key, use knowledge of the real world (what is
going to stay unique!)
F NAME
L NAME
E12345
John
Chopples
E12367
Kent
Danial
E54321
Michal
Blurp
E5099
Amber
Rumpel
E54344
Lea
John
Primary Keys
A primary key for a table (entity type) is a candidate key that the DB designer has
chosen as being the main way of uniquely identifying a row (entity).
Primary keys are the main way of identifying target entities in entity relationships,
e.g., the way to identify someones employing organization.
Cannot have null values (A null value is no value, it is NOT equal to a zero or a
blank space).
For efficiency (and correctness) reasons, the simpler that primary keys are, the
better.
Typical primary keys examples are Identity numbers (of people, companies,
products, courses, etc.), or combinations of them with one or two other
attributes.
Composite key: Composed of more than one attribute
superkey
primary key
candidate
key
Functional dependence
Attribute B functionally dependent on A if all rows in table that agree in value for A
also agree in value for B
E.g., the collection DAY-NUMBER, MONTH and YEAR specifying birthdate in a table about people could determine DAY-NAME,
We alternatively say that DAY-NAME is functionally dependent on DAYNUMBER, MONTH and YEAR.
Foreign Keys
Remember!! Relationships are represented by associative linking by means of shared
attributes
Standardly, a relationship is represented by means of Foreign keys.
Foreign key: an attribute whose values match primary key values in the related table
Referential integrity: a set of attributes in the first (referencing) relation is a Foreign
Key if its value always either
matches a Candidate Key value in the second (referenced) relation, or
is NULL
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Is this redundancy?
Multiple occurrences of values not redundant when needed to
make the relationship work
Redundancy occurs only when there is unnecessary duplication
of attribute values
Foreign keys control typical data redundancies by using common
attributes shared by tables
Referential Integrity
When relations are updated, referential integrity can be violated
This usually occurs when a referenced tuple is updated or deleted
There are a number of options:
RESTRICT - stop the user from doing it
CASCADE - let the changes flow on
NULLIFY - make values NULL
Integrity Rules
Many RDBMs enforce integrity rules automatically
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Summary
Relational database model offers a logical view of data.
Keys are central to the use of relational tables
Keys define functional dependencies
Each table row must have a primary key that uniquely identifies all
attributes
Tables linked by common attributes (foreign keys)
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 4 (Wednesday)
Database Modeling
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Overview
Stages of Database development
Understand the basic data modeling concepts and importance
What are the basic data-modeling building blocks?
2. Design Stage
Requirements information is processed into a data model (database design)
3. Implementation Stage
Physical implementation of the developed database design into a real world
database application
Data Model
Data model is the collection of concepts that can be used to describe
the structure/design of the database.
Designers, programmers, and end users see data in different ways
Different views of same data lead to designs that do not correctly
present organizations operation
Data modeling reduces complexities of database design and organizes
data for various users
It Improves the understanding of the organization for which the
database design is developed
Entity Relationship Model is the most successful database model
designer
application
programmer
end user
Entities
Entities: are real-world objects, distinct from other objects, for which
we intend to collect data (e.g. person, place, event)
Entities are just things which data are to be collected and stored in a
Table.
A row in a table corresponds to an entity instance.
Entity Set: a group of entities of the same type, e.g., all employees.
Examples of database entities in a company business environment.
Employee
Department
What else??
Attributes
Attribute: describes a characteristic of an entity.
Each Attributes has a data type and other properties
Attributes of entities of a given type are the names of the different
pieces of information that need to be stored for entities of that type.
Attributes just the column names for the table for the entity type.
E.g., entities of the type Employee could have the following attributes:
Employee ID number, last name, first name, phone number, ageetc.
The ______ operator is used to compare a value to a list of literals values that have been specified.
(A) BETWEEN
(B) ANY
(C) IN
(D) ALL
(B) degree.
(C) tuple.
(D) domain.
(A) Groups
(B) Table
(C) Attributes
(D) Switchboards
Relationship
A relationship is an association between entities, e.g.:
An employee works in a single department
A department employs several employees
Note that they mostly described as verbs.
Relationship Set: Collection of similar relationships.
Same entity set can participate in different relationship sets.
Relationship Connectivity
Relationships are importantly categorized as to uniqueness or multiplicity of
entities at either end connectivity.
Has a big effect on DB design.
Enrolls
Student
Many-to-Many relationship
1
Teaches
Professor
Class
One-to-Many relationship
1
Class
Student
Has
One-to-One relationship
Graduation
Report
Relationship Cardinality
Relationships can be further specified as to how many entities allowed or
required at either end cardinality.
Has significant effect on DB design.
Professor
(0,3)
Teaches
(1,1)
One-to-Many relationship
Class
Student
(1,6)
Enrolls in
(5,35)
Many-to-Many relationship
Class
Relationship Participation
Optional [in a particular direction, X to Y]:
Summary
Database development comprises of three main stages
Data modeling Improves the understanding of the organization for
which the database design is developed
Entity, Attribute and Relationship are the main blocks for generating a
database model
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 5 (Friday)
Conceptual Data Model (Part 2)
Entity Relationship Diagrams (ERD)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Identifier attributes
Simple versus Composite Attribute
Single-Valued versus Multivalued Attribute
Derived Attribute
Logical Schema
Physical
Design
Physical Schema
Overview
How relationships between entities are defined and
graphically presented
Relationship Connectivity in ERD
Relationships Cardinality in an ERD
Relationship Participation in ERD
Relationship Degree in ERD
Weak Entities in ERD
Associative (Composite) Entities
Example of ERD that represents a business situation
Many-to-Many
1-to-Many
1-to-1
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Bridging entity types are weak, but this is not normally shown
Entity: DIVISION
Attributes DIVISION ID, business sector name
Entity: DEPARTMENT
Attributes Department ID, Department name and
location
Entity: PROJECT
Attributes Project ID, Project name and Project
Budget.
<operates>
M [DEPARTMENT]
[EMPLOYEE] 1
<runs>
1 [DIVISION]
[EMPLOYEE] 1
<manages>
1 [DEPARTMENT]
[EMPLOYEE] N
<assigned>
[DEPARTMENT] 1 <employs>
M [PROJECT]
M [EMPLOYEE]
ERD
BSName
ID
1
ID
M
operates
DIVISION
1
DEPARTMENT
(1,1)
(1,N)
1
Name
Location
(1,1)
(1,1)
(1,N)
Fname
Lname
employs
manages
Name
1
runs
(0,1)
EMPLOYEE
(0,1)
ID
(0,1)
(0,N)
(1,1)
1
M
DoB
ASSIGN
(1,1)
(1,N)
ID
Name
Budget
PROJECT
Title
M
1
Salary
ERD
BSName
ID
Location
1
1
DEPARTMENT
(1,1)
(1,N)
1
ID
M
operates
DIVISION
Name
(1,1)
(1,1)
(1,N)
Fname
Lname
employs
manages
Name
1
runs
(0,1)
EMPLOYEE
(0,1)
ID
Working_Hours
(0,1)
(0,N)
(1,1)
1
M
DoB
ASSIGN
(1,1)
(1,N)
ID
Name
Budget
PROJECT
Title
M
1
Salary
Announcements
Next Friday lecture 7th of Nov will be 13:00
14:00 in Main Lecture Theatre Arts.
Next week there will be no lab session as you
will have a non-technical exercise.
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 5 (Wednesday)
Conceptual Data Model
Entity Relationship Diagrams (ERD)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Candidate key
A superkey without unnecessary attributes
Primary Key
A candidate key selected to uniquely identify all other attributes and
cant contain Null entries.
Composite key
Composed of more than one key attributes
Overview
The Conceptual Database Model
The Entity Relationship Diagram (ERD) model
The main characteristics and notations of entity
relationship components
Classes of Attributes
Identifier attributes
Simple versus Composite Attribute
Single-Valued versus Multivalued Attribute
Derived Attribute
Logical Schema
Physical
Design
Physical Schema
Logical Schema
Physical
Design
Physical Schema
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Identifier Attributes
Identifier Attributes (primary Key) is underlined
In the below example Ssn (Social Security number) is underlined
as it represent the identifier attribute (primary Key)
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Multivalued Attribute
Multivalued Attribute
Another possibility: Within original entity type, split the
attribute into several different attributes corresponding to
different natural components of the entity.
Disadvantages: The attribute
may in reality need to be split
differently for different entities
in the entity type (e.g. different
cars).
The attribute may not have
naturally namable aspects at
all. E.g., imagine blotches of
color in random places on a car.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Multivalued Attribute
Another possibility: Within original entity type, split the
attribute into several different attributes not corresponding
to specific components of the entity.
E.g., have attributes called Colour1, Colour2, , Colour6.
Advantage: copes with the no-identifiable-components problem and
the different-split problems.
Disadvantages:
Have to set aside enough columns to accommodate the conceivable
max, but if this max is large and not often approached then have a lot
of wasted space.
Multivalued Attribute
Often Better: Replace the attribute by a new 1:M relationship to a new
entity type holding the original attributes data.
If the components of the original attribute are conceptually
distinguishable in a natural way, the new entity can have an attribute
whose values identify those components.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Derived Attribute
A derived attribute its value is computed
from other attributes.
It is indicated in ER diagram using a
dotted line connecting the attribute with
the entity.
e.g.: employee age can be calculated from
the date of birth and current date.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Announcements
Next lecture Friday 31st of October (ONLY in
week 5) will be 13:00 14:00 in 101, Haworth
(Y2 in Edgbaston Campus Map ).
The following Friday lectures (week 6-11) will
be 13:00 14:00 in Main Lecture Theatre
Arts.
This week (week 5) Hand-out and exercise has
been released on canvas.
Summary
Uses ERD to represent conceptual database as
viewed by end user
ERMs main components:
Entities
Relationships
Attributes
Identifier attributes
Simple versus Composite Attribute
Single-Valued versus Multivalued Attribute
Derived Attribute
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 6 (Friday)
Logical Data Model (Mapping E/R design to relational schema) Part 2
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Announcements
So far we have covered most of Chapters (1, 3, 4, 5 and 7) in the
reference text book
C. Coronel, S. Morris, P. Rob & K. Crockett,
Database Principles: Fundamentals of Design, Implementation and
Management, 10th Edition, 2013.
Next week we will start Chapter 8.
Relational model
SQL
Entity
Instance
Attribute
Relationship
(1:M,1:1,M:N)
Identifying Attribute
Relation
Tuple
Attribute
Foreign Key
Table
Row
Column or Field
Foreign Key
Primary Key
Primary Key
Overview
Relationship Degree (Revised)
What is the recursive Symmetry Relationships
Implementation of the non-symmetric 1:M recursive relationship
Implementation of the non-symmetric N:M recursive relationship
Implementation of the symmetric 1:1 recursive relationship & nonredundant implementations
The problem of Symmetry
Redundant Relationships
Employee
Manages
Works
Employee
Customer
Department
Issue invoice
Employee
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
CFR is just like the bridging entity types youve seen before,
but has 3 links to other types instead of 2
Can have partial recursion: just some of the entity types involved in a
relationship could be the same.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
if eRf then fRe (i.e., IF R relates entity e of type E to entity f of type F, then it
must ALSO relate f to e.)
E.g.: marriage, being-sibling-of.
Recursive relationships cause major redundancy problems when ALSO
symmetric.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
itself. NB: its first two columns both refer to PARTs PK but must be
differently named.
No redundancy problem.
Redundancy problem!!
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
1) As previouslyredundant .
2) MARRIED_V1 is just a bridging entity type: still redundant.
3) MARRIAGE together with MARPART act as a sort of bridge. Non-redundant.
Redundant Relationships
Occur when there are multiple relationship paths between related
entities
Main concern is that redundant relationships remain consistent
across model
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 6 (Wednesday)
Logical Data Model ( Mapping E/R design to relational schema) Part 1
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Announcements
This week there will be no lab session.
Assignment 5 will be conceptual (designing an ERD) and it won't
involve any practical work.
Assignment 5 (unassessed) has been released on canvas.
In week 8 you will have an one line test on canvas
It will become available on Friday 21/11/2014 (on canvas) accounting
for 10% of the module mark. (The exact time will be announced on
canvas soon)
Once you start you have 60 minutes to complete it.
Overview
Mapping E/R design to relational schema
Mapping entity sets
Mapping weak entity sets
Mapping Multivalued Attribute
Mapping relationship sets
1:M Relationships
1:1 Relationships
N:M Relationships
Strong versus weak Relationships
Strong versus weak Entities
Logical Design
Logical design translates the conceptual design (ER mode) into the
internal model (relational schema) for a selected DBMS.
E/R Diagram
Entity
Relational model
Relation
SQL
Table
Instance
Attribute
Relationship
(1:M,1:1,M:N)
Identifying Attribute
Tuple
Attribute
Foreign Key
Row
Column or Field
Foreign Key
Primary Key
Primary Key
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Logical Design
E/R Diagram
Relational model
SQL
Entity
Instance
Attribute
Relationship
(1:M,1:1,M:N)
Identifying Attribute
Relation
Tuple
Attribute
Foreign Key
Table
Row
Column or Field
Foreign Key
Primary Key
Primary Key
Parent
Child
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
NAME
PHONE
ORG_ID
AGE
9568876
Chopples
0121-414-3816
E22561
37
2544799
Blurp
01600-719975
E85704
21
1698674
Rumpel
07970-852657
E22561
88
1800748
Dunston
0121-414-3886
E22561
29
ORGANIZATION
employs
EMPLOYEE
One-to-Many relationship
ORGANIZATION
ORG_ID
EMPL NAME
ADDRESS
NUM EMPLS
SECTOR
E48693
BT
BT House,
London,
1,234,5678
Private TCOM
E85704
Monmouth
School
Hereford Rd,
Monmouth,
245
Private 2E
University of
Birmingham
Edgbaston Park
Rd, .
3023
E22561
Public HE
PHONES
PERS-ID
NAME
EMPL ID
AGE
PHONE
TYPE
PERS-ID
STATUS
9568876
Chopples
E22561
37
0121-414-3816
office
9568876
OK
2544799
Blurp
E85704
21
01600-719975
home
5099235
FAULT
1698674
Rumpel
E22561
88
0121-440-5677
home
1698674
OK
5099235
Biggles
E22561
29
07970-852657
mobile
2544799
UNPAID
or in the CLASS table: some classes will each have several students listed
or both.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
An entity set that does not have sufficient attributes to form a primary key is a
(A) strong entity set.
(B) Diamond
(C) dependent on both hardware and software . (D) independent of both hardware and software.
Strong Relationships
Strong (identifying) relationships
Exists when PK of related entity contains PK component of parent entity
A relationship from entity type A to entity type B, mediated by having As primary key
(PK) as a foreign key in B, is strong when Bs PK contains As PK.
Includes the case of Bs PK just being the same as As PK.
E.g., A = Customers, B = Dependants, where
As PK is: CUST_ID
Dependants is weak entitity, because there is a strong relationship to it from Customers, and
Dependants is existence-dependent on Customers via this relationship.
Strong Relationship
CUSTOMERS (the A type)
CUST-ID
NAME
PHONE
EMPL ID
AGE
9568876
Chopples
0121-414-3816
E22561
37
2544799
Blurp
01600-719975
E85704
21
1698674
Rumpel
07970-852657
E22561
88
1800748
Dunston
0121-414-3886
E22561
29
FIRST NAME
CONNECTION
LIVES_WITH
2544799
John
civil partner
TRUE
1698674
Mary
child
FALSE
1698674
Mary
spouse
FALSE
1698674
David
child
TRUE
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 7 (Wednesday)
SQL Data Definition
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Overview
How to use SQL for data administration to create databases and tables.
SQL Data types
SQL Constraints
NOT NULL constraint
UNIQUE constraint
DEFAULT constraint
CHECK constraint
Primary Key
Foreign Key
DROP TABLE
ALTER TABLE
INSERT, UPDATE, and DELETE
Create DB Schema (Group of database objects that are related to each other)
Creating a Table
CREATE TABLE <name> (
<col-def-1>,
<col-def-2>,
:
<col-def-n>,
<constraint-1>,
:
<constraint-k>);
Data Types
Data type selection is usually dictated by nature of data and by
intended use
Supported data types:
Date/time
Data types
SQL Constraints
Each constraint is given a name - Access requires a name, but some others dont
Primary Keys
Primary Keys are defined through constraints
A PRIMARY KEY constraint also includes a UNIQUE constraint and makes the
columns involved NOT NULL
The <details> for a primary key is a list of columns which make up the key
CONSTRAINT <name>
PRIMARY KEY
(col1, col2, )
Example
CREATE TABLE distributors (
did integer,
name varchar(40),
PRIMARY KEY(did) );
Unique Constraints
As well as a single primary key, any set of columns can be specified as UNIQUE
Example
CREATE TABLE films (
code char(5) CONSTRAINT firstkey PRIMARY KEY,
title varchar(40) NOT NULL,
did integer NOT NULL,
date_prod date,
kind varchar(10),
CONSTRAINT production UNIQUE(date_prod));
CREATE TABLE distributors (
did integer PRIMARY KEY DEFAULT nextval('serial'),
Foreign Keys
Foreign Keys are also defined as constraints
Example
CREATE TABLE cities
Example
CLASS_CODE integer,
ENROLL_GRADE char(6) NOT NULL,
PRIMARY KEY (STU_NUM,CLASS_CODE),
ON DELETE/ ON UPDATE
When the data in the referenced columns is changed, certain actions
are performed on the data in this table's columns.
The ON DELETE clause specifies the action to perform when a
referenced row in the referenced table is being deleted.
Likewise, the ON UPDATE clause specifies the action to perform when
a referenced column in the referenced table is being updated to a
new value.
Example
CREATE TABLE AS
Define a new table from the results of a query
CREATE TABLE films_recent AS
SELECT * FROM films WHERE date_prod >= '2002-01-01;
Deleting Tables
To delete a table use
DROP TABLE
[IF EXISTS]
<name>
Example:
Changing Tables
Sometimes you want to change the structure of an existing table
One way is to DROP it then rebuild it
This is dangerous, so there is the ALTER TABLE command instead
ALTERing Columns
To add or remove columns use
ALTER TABLE <table>
ADD COLUMN <col>
ALTER TABLE <table>
DROP COLUMN <name>
Examples
ALTER TABLE Student
ADD COLUMN
Degree VARCHAR(50)
ALTER TABLE Student
ALTERing Constraints
To add or remove columns use
ALTER TABLE <table>
ADD CONSTRAINT
<definition>
ALTER TABLE <table>
DROP CONSTRAINT
<name>
Examples
ALTER TABLE Module
ADD CONSTRAINT
ck UNIQUE (title)
ALTER TABLE Module
DROP CONSTRAINT ck
The basic data type char(n) is a _____ length character string and varchar(n) is _____
length character.
A) Fixed, equal
B) Equal, variable
C) Fixed, variable
D) Variable, equal
Updates that violate __________ are disallowed .
A) Integrity constraints
B) Transaction control
C) Authorization
D) DDL constraints
Which of the following SQL command can be used to modify basic storage
characteristic of a database table?
A) MODIFY
B) UPDATE
C) CHANGE
D) ALTER
INSERT
INSERT INTO
<table>
(col1, col2, )
VALUES
(val1, val2, )
INSERT
Student
INSERT INTO Student
(ID, Name, Year)
VALUES (2, Mary, 3)
ID
Name
Year
1
2
John
Mary
1
3
Student
Student
ID
Name
Year
John
ID
Name
Year
1
2
John
Mary
Student
INSERT INTO Student
VALUES (2, Mary, 3)
ID
Name
Year
1
2
John
Mary
1
3
UPDATE
UPDATE <table>
SET col1 = val1
[,col2 = val2]
[WHERE
<condition>]
UPDATE
Student
Student
ID
Name
Year
1
2
3
4
John
Mark
Anne
Mary
1
3
2
2
UPDATE Student
SET Year = 1,
Name = Jane
WHERE ID = 4
ID
Name
Year
1
2
3
4
John
Mark
Anne
Jane
1
3
2
1
Student
UPDATE Student
SET Year = Year + 1
ID
Name
Year
1
2
3
4
John
Mark
Anne
Mary
2
4
3
3
DELETE
Removes all rows which satisfy the
condition
DELETE FROM
<table>
[WHERE
<condition>]
DELETE
Student
DELETE FROM
Student
WHERE Year = 2
Student
ID
Name
Year
1
2
3
4
John
Mark
Anne
Mary
1
3
2
2
DELETE FROM Student
ID
Name
Year
1
2
John
Mark
1
3
Student
ID
Name
Year
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 7 (Wednesday)
The Extended Entity Relationship (EER) Model
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Announcements
The test will be online on canvas
You need to make sure that you are registered on the correct Module
(Fundamentals/ICY) or on canvas.
Test will be Multiple Choice Questions (20 questions)
It will cover all of the concepts that we have discussed so far including this weeks
lectures (week7) but not the next week (week 8).
The ONLINE TEST accounts for 10% of the module mark
Test will be available on Friday 21 of November at 3 pm and will close (same day) on
Friday 21 of November at 10 pm
The last opportunity for you to take the test is from 9pm to 10pm
Once you start the test it should take you only 60 minutes to complete the test.
Announcements
The test is marked automatically and you are going to see your mark
right away after you finish the test
Correct answers will be released on Saturday on canvas.
Last years class test and answers are released on canvas.
If you are entitled for extra time you need to contact welfare ASAP
Today we are staring chapter 8 in the book.
C. Coronel, S. Morris, P. Rob & K. Crockett, Database Principles: Fundamentals of Design,
Implementation and Management, 10th Edition, 2013.
Overview
About the extended entity relationship (EER) models main constructs
Supertype and subtype relationships
Why and When to Consider Supertypes and Subtypes?
Relationships and Subtypes
Generalization and specialization
Completeness Constraint
Disjoint and Overlapping Constraints
Mapping Supertype/Subtype Relationships to Relational Data Model
Summary
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Generalization
Identifies more generic/general entity supertype from lower-level entity
subtypes
Bottom-up process
Based on grouping common characteristics and relationships of the subtypes
Inheritance
Enables entity subtype to inherit attributes and relationships of
supertype
All entity subtypes inherit their primary key attribute from their
supertype
At implementation level, supertype and its subtype(s) maintain a 1:1
relationship
Completeness Constraint
Specifies whether entity supertype occurrence must be a member of at least one
subtype
Partial completeness
Symbolized by a single line
Some supertype occurrences that are not members of any subtype
Total completeness
Symbolized by a double line
Every supertype occurrence must be member of at least one subtype
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Overlapping subtypes
An instance of the supertype could be more than one of the subtypes
Symbolized by a the letter o
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
When an entity instance must be a member of only one subtype, it is which of the following?
A) Disjoint with total specialization
When an entity instance may be a member of multiple subtypes or it does not have to be a member of a
subtype, it is which of the following?
A) Disjoint with total specialization
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 10th Ed.
Source of Image: Modern Database Management 6th Edition, Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden
Summary
Extended entity relationship (EER) model adds semantics to ER model via entity supertypes and
subtypes
Entity supertype is a generic entity type related to one or more entity subtypes
Specialization hierarchy depicts arrangement and relationships between entity supertypes and
entity subtypes
Partial completeness : Some supertype occurrences that are not members of any subtype
Total completeness : Every supertype occurrence must be member of at least one subtype
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 8 (Friday)
Functional Dependencies and Normalization for Relational Databases
(part 2)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Normal Forms
Normalization can be divided into a series of stages called normal
forms, giving more and more protection:
1NF Relations
2NF Relations
3NF Relations
BCNF Relations
4NF Relations
Composite Keys
Overview
It is in 1NF and
Every non-prime attribute A in R is fully functionally dependent on
the primary key
It includes no partial dependencies (No attribute is dependent
on only portion of primary key) if
It is in 1NF
It includes no partial dependencies
It is in 2NF
It contains no transitive dependencies
A,B
A,C
C,D
B,D
Student ID
Student ID
Staff ID
Class Code
Staff ID
Class Code
Class Code
Staff ID
Enroll_Grade
Enroll_Grade
Student ID
Class Code
Enroll_Grade
Class Code
Staff ID
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 8 (Wednesday)
Functional Dependencies and Normalization for Relational Databases
(part 1)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Overview
Motivation
What normalization is and what role it plays in the database design
process
Identify possible insertion, deletion, and update anomalies in a
relation
How normalization and ER modeling are used concurrently to
produce a good database design
What are the normal forms 1NF, 2NF, 3NF, BCNF, and 4NF
Identify functional dependencies, determinants, and dependent
attributes
First Normal Form
Motivation
Consider that you are requested to design a database from an
existing data from spreadsheets as given in the table below.
SKU implies Stock Keeping Unit
The process of
decomposing
unsatisfactory "bad"
relations by breaking
up their attributes
into smaller relations
is known as
Normalization
Deletion Anomaly
Suppose we delete the data for repair number 2100.
When we delete this row (the second one), we remove not only data about the
repair, but also data about the machine itself.
We will no longer know, for example, that the machine was a Lathe and that its
AcquisitionPrice was 4750.00.
When we delete one row, the structure of this table forces us to lose facts about
two different things, a machine and a repair.
Insertion Anomaly
Now suppose we want to enter the first repair for a piece of equipment.
To enter repair data, we need to know not just RepairNumber, RepairDate, and
RepairCost, but also ItemNumber, EquipmentType, and AcquisitionCost.
If we work in the repair department, this is a problem, because we are unlikely to
know the value of AcquisitionCost.
The structure of this table forces us to enter facts about two entities when we
just want to enter facts about one.
Update Anomaly
Suppose we update the last row of the following table using the data (100, Drill
Press, 5500, 2500, 08/17/09, 275).
The drill press has two different AcquisitionCosts (data inconsistency).
Equipment cannot be acquired at two different costs. If there were, say, 10,000
rows in the table, however, it might be very difficult to detect this error.
(100,
Drill Press,
5500,
2500,
08/17/09,
275)
Normal Forms
Normalization can be divided into a series of stages called normal
forms, giving more and more protection:
1NF Relations
2NF Relations
3NF Relations
BCNF Relations
4NF Relations
Normal Forms
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
ID
Name
Soc_Sec_Nbr
Major
Dept
Transitive dependency
A, B and C are attributes of a relation such that A B and B C,
then C is transitively dependent on A via B (provided that A is not
functionally dependent on B or C)
Partial dependency
Transitive dependency
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Dependency diagram:
No
repeated
Groups
Source of Image: Database Principles: Fundamentals of Design, Implementation and Management, 2nd Ed.
Example of First
Normal Form
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 9 (Friday)
Mathematical background to tables
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Motivation
Manipulation of data
(query
and
update
operations) corresponds
to operations on relations
Relational algebra
First described by Codd at IBM,
It is a family of algebra with a well-founded semantics used for
modelling the data stored in relational databases, and defining
queries on it.
Relational algebra contains two kinds of operators:
common a set operations (such as union, intersection, and
cartesian product),
operators specific to relations (for example projecting on one of
the columns) selection (keeping only some rows of a table)
Relational Model
Emp is a relation
and it is a set with eight members
A mathematical relation is a set of
tuples: sequences of values.
Each tuple corresponds to a row in a
table.
Ech tuple can be considered as a
member/element in the set.
S = {34, SHF, 59, UoB}, where SHF is a name for me and UoB is a name for
this university,
means that
S is the set consisting of (exactly) the following four items:
the abstract number 34, me, the abstract number 59, this university.
Basics, contd
{34, SHF, 59, UoB} = {UoB, 59, 34, SHF, SHF, 34}
Another Notation
{n | n is an integer, n > 301} =
The set of n such that n is an integer and n > 301.
(Actually, this notation is a slight simplification.)
Membership Relationship
a A means that a is a member of A.
5
{4,5}
{3, {4,5}, 4, 6}
{5}
{3, {4,5}, 4, 6}
{4,6}
{3, {4,5}, 4, 6}
(Reflexivity)
If A B and B A then A = B.
(Antisymmetry)
If A B and B C then A C.
(Transitivity)
Bad Associations
Caution: if an operation is not associative, the position of
parentheses is normally important.
In arithmetic, division is non-associative.
(x/y)/z is usually a different value from x/(y/z).
People
Tuples in a Table
PERS-ID
NAME
AGE
9568876A
Chopples
37
2544799Z
Blurp
1698674F
Rumpel
88
Tuples in General
A tuple in general is an ordered sequence of items of any sort. We will only deal with
finite tuples. Items CAN be duplicated.
Can also be called a vector in other CS terminology.
Cartesian Products
The set of all possible tuples formed from some list of sets is called the Cartesian
product of the sets.
Notation, e.g.:
DEFGH
if D, E, F, G, H are the setsnot necessarily different.
The tuples are all possible tuples of the form
<d, e, , h>
where
d D, e E, , h H
Examples
Let A = {3, 8, 2} and B = {jjj, bb}.
Then A B =
{ <3, jjj>, <3, bb>, <8, jjj>, <8, bb>, <2, jjj>, <2, bb> }.
B B = { <jjj, jjj>, <jjj, bb>, <bb, jjj>, <bb, bb>}.
A = = A
A {TRUE} = { <3, TRUE>, <8, TRUE>, <2, TRUE> }
Relations
Any subset at all of a Cartesian product is called a relation on the sets in question
(D, E, above)
even the whole of the product (even if infinite)
and even the empty set.
I.e., a relation on D, E, , H is just some set of tuples that are each of form <d,e,
, h> where d D, e E, , h H.
Examples
Let A = {3, 8, 2} and B = {jjj, bb}.
The Cartesian product A B =
{ <3, jjj>, <3, bb>, <8, jjj>, <8, bb>, <2, jjj>, <2, bb> }.
<2, jjj>}
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 9 (Wednesday)
Functional Dependencies and Normalization for Relational Databases
(part 3)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Announcements
Assignment 9 (assessed accounts for 10% of the module mark) will be
available on canvas today.
No lab session this week because you will be starting the conceptual
phase of assignment 9. However, you are very welcomed to attend
the lab but no demonstrators will be available.
Overview
Fourth Normal Form (4NF)
Normalization and Database Design
Denormalization
Summary
Assignment 9 specifications.
Definition of MVD
A multivalued dependency of some attribute X on an attribute-set D
is like a functional dependency except that X is allowed to have
several values for a given value of D.
The crucial point is that once the D value is specified, the X values are
independent of other attributes.
So, we can think of X as a multivalued attribute implemented by
putting different values in different rows, where the set of X values is
fully determined by just the value of D.
Not 4 NF Example
Assume the following relation with multivalued dependency:
Employee (Eid:pk1, Languages:pk2, Skills:pk3)
Recall that a relation is in BCNF if all its determinant are candidate
keys.
Because relation Employee has only one determinant (Eid, Language,
Skill), which is the composite primary key.
Since the primary is a candidate key, R is in BCNF.
However this relation has a MVD
Eid --->> Languages
Eid --->> Skills
Languages and Skills are independent.
Language
English
Kurdish
English
Kurdish
Arabic
Skill
Teaching
Politics
Politics
Teaching
Singing
Language
English
Kurdish
English
Kurdish
Arabic
English
Arabic
English
Skill
Teaching
Politics
Politics
Teaching
Singing
Cooking
Cooking
Singing
Change to 4NF
By placing the multivalued attributes in tables by themselves we can
convert the table to the following:
Eid
Language
Skill
Eid --->> Skills
Eid
Language
Eid
Skill
4 NF Example
Assume the following relation:
Employee (Eid:pk1, Language:pk2, Skill:pk3)
Eid
100
100
100
200
200
Language
English
Kurdish
French
English
Arabic
Skill
Teaching
Politic
Cooking
Cooking
Singing
4 NF Example (conti...)
Assume the following relation with multi-value dependency:
Employee (Eid:pk1, Languages:pk2, Skills:pk3)
4 NF Example (conti...)
Thus employee 100 when she teaches, she uses English; but when she cooks, she
uses French. This relation is in fourth normal form.
Eid
100
100
100
200
200
Language
English
Kurdish
French
English
Arabic
Skill
Teaching
Politic
Cooking
Cooking
Singing
1NF < 2NF < 3NF < BCNF ((and 3NF < 4NF))
((Also BCNF < 4NF under the second definition of 4NF.
BCNF and 4NF guard against relatively unusual situations. BCNF is
more disruptive to achieve than 2NF or 3NF.
3NF is a reasonable target, but BCNF, 4NF etc. may also need to be
considered.
Non-Normalization/Denormalization
If tables decomposed to conform to normalization requirements:
Number of database tables expands
Summary
Normalization is used to minimize data redundancies
First three normal forms (1NF, 2NF, and 3NF) are most commonly
encountered
Table is in 1NF when it doesn't contain a repeated group attribute. All
key attributes are defined
Table is in 2NF when it is in 1NF and contains no partial dependencies
Table is in 3NF when it is in 2NF and contains no transitive
dependencies
Table that is not in 3NF may be split into new tables until all of the
tables meet 3NF requirements
Summary (continued)
Normalization is important partbut only partof the design
process
Table in 3NF may contain multivalued dependencies
Numerous null values or redundant data
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 10 (Wednesday)
Relational Algebra (part 1)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Relational Algebra
Intermediate language used within DBMS
The basic set of operations for the relational model
Procedural
Relational Algebra
A formal language (based on operators and a domain of values) that
aims to perform queries in relational databases
It is often considered to be an integral part of the relational data
model.
Why is it important??
It provides a formal foundation for relational model operations.
It is used as a basis for implementing and optimizing queries in the
query processing and optimization modules that are integral parts of
relational database management systems (RDBMSs),
SQL
query
Optimized
Relational
algebra
expression
Query
execution
plan
Executable
code
Code
generator
parser
Query optimizer
DBMS
Select Operator
Produce table containing subset of rows of argument table satisfying condition
Select Operator
SQL:
SELECT * FROM WHERE
Note: its the WHERE part that is actually doing the selection
according to a criterion.
Select Operator
SQL:
SELECT *
FROM Person
WHERE Hobby=stamps
Relational Algebra: sHobby=stamps(Person)
Person
Id
1123
1123
5556
9876
Name
John
John
Mary
Bart
Address
123 Main
123 Main
7 Lake Dr
5 Pine St
Hobby
stamps
coins
hiking
stamps
Id
1123
9876
Name Address
John 123 Main
Bart
5 Pine St
Hobby
stamps
stamps
Project Operator
Produces table containing subset of columns of argument table
Project Operator
SQL:
SELECT column specs FROM
Project Operator
SQL:
1123
1123
5556
9876
Name
Address
Hobby
John
John
Mary
Bart
123 Main
123 Main
7 Lake Dr
5 Pine St
stamps
coins
hiking
stamps
Name Hobby
John
John
Mary
Bart
stamps
coins
hiking
stamps
Expressions
Id, Name (s
Id
Name
Address
1123
1123
5556
9876
John
John
Mary
Bart
Hobby=stamps OR Hobby=coins
Hobby
123 Main
123 Main
7 Lake Dr
5 Pine St
stamps
coins
hiking
stamps
Id
(Person) )
Name
1123 John
9876 Bart
Result
Person
13
Union-compatible relations
Result of combining two relations R and S with a set operator
is a relation => all its elements must be tuples having same
structure
Hence, scope of set operations limited to union compatible
relations
Two relations A and B are union-compatible if they have the
same
number of columns and corresponding
columns have the same domains.
Union
Let A and B be two union-compatible relations.
Result of A B, contains all rows A in and all rows in B, with duplicate rows eliminated
(B)
(A)
(C)
To retrieve the Social Security numbers of all employees who either work in
department 5 or directly supervise an employee who works in department 5,
using the UNION operation
Alternative soluion
Note renaming the result set.
Difference
Let R and S be two union-compatible relations.
Then their difference R - S is a relation which contains tuples which are in R but
not in S
Intersect
Let R and S be two union-compatible relations.
Then their intersection is a relation R S which contains tuples which are both in R and S
Note that INTERSECTION can be expressed in terms of union and set difference as follows:
R S = ((R S) (R S)) (S R)
Cross-Join or Product
SQL:
SELECT * FROM two [or more] tables
NB: its the mere listing of the tables that does the Product, but its possible
also to write:
SELECT * FROM T1 CROSS JOIN T2 CROSS JOIN ...
Relational algebra notation:
Result table is T1 T2 where T1 and T2 are the given tables.
Each row of T1 paired with each row of T1.
Yields a table containing all concatenations of whole rows from first given
table with whole rows from second given table.
Cross-Join or Product
If second table also had a PRICE attribute, then the product would have a Table1.PRICE
attr. and a Table2.PRICE attr.
JOIN operation
Join (various types)
Allows us to join related rows from two or more tables
Its an important feature of the relational database idea
Condition-Join
R c S s c ( R S)
Where R and S are relations and c is the condition applied.
Ramez A. Elmasri, Shankrant B. Navathe. 1999. Fundamentals of Database Systems (3rd ed.). Carter
Shanklin (Ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.
Ramez A. Elmasri, Shankrant B. Navathe. 1999. Fundamentals of Database Systems (3rd ed.). Carter
Shanklin (Ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.
Ramez A. Elmasri, Shankrant B. Navathe. 1999. Fundamentals of Database Systems (3rd ed.). Carter
Shanklin (Ed.). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA.
Announcements
Lab session next week to catch up with any of the exercise that you have
missed or to complete the practical requirements of assignment 9.
Next Wednesdays lecture (week 11) will be in LT2, Gisbett Kapp (G 8)
from 12:00 pm to 1:00 pm (last lecture)
No lecture on Friday (week 11).
Normalization hand-outs /exercise has been released on canvas.
Relational Algebra hand-outs /exercise has been released on canvas.
Module evaluation Forms are today (last 10 minutes of the lecture)
SQL
query
Optimized
Relational
algebra
expression
Query
execution
plan
Executable
code
Code
generator
parser
Query optimizer
DBMS
JOIN operation
Join (various types)
Allows us to join related rows from two or more tables
Its an important feature of the relational database idea
Joining has been implicitly important because of the use of mutli-table queries
and the use of WHERE to test for attribute equality between tables.
Denoted by
Cross-Join or Product
Perform a cross join that yields specified attributes
Overview
Review on Condition Join
Equijoin Join
Natural Join
Outer Joins
Left
Right
Full
Condition-Join
(Relation 1
condition
Relation 2)
Condition-Join Example
Retrieve the department names of employees who earn more than
40000 pounds
DName(EMPLOYEE
Dno=Dnumber AND Salary > 40000 DEPARTMENT)
Equijoin Join
The most common use of JOIN involves join conditions with equality
comparisons only.
The only comparison operator used is =,
Example of EQUIJOINs.
Note that, in the result of an EQUIJOIN we always have one or more pairs of
attributes that have identical values in every tuple.
Mgr_ssn and Ssn are identical in every tuple of DEPT_MGR (the EQUIJOIN
result)
Natural Join
Because one of each pair of attributes with identical values is
superfluous, a new operation called NATURAL JOIN was created to get
rid of the second (superfluous) attribute in an EQUIJOIN condition.
NATURAL JOIN is basically an EQUIJOIN followed by the removal of
the duplicate columns from the result
Used when tables share one or more common attributes with same
names.
SQL Syntax:
SELECT column-list FROM table1 NATURAL JOIN table2
AGENT)
Step 1: PRODUCT
Step 2: SELECT
to get equal agent codes in each row
SELECT is performed on the resulting table to yield only the rows for which the
join-attribute values (e.g. AGENT_CODE values) are equal
Step 3: PROJECT
to get just one agent column
My Plan
Get the John Smith information
Get project numbers he works on
Get employee names working on these projects (including John
Smith)
Exclude John Smith from the final result
References
Source of images in this lecture:
Database Principles: Fundamentals of Design, Implementation and
Management, by Stephen Morris, Peter Rob, Carlos Coronel
Fundamentals of Database Systems by Ramez Elmasri, Shamkant B. Navathe
Fundamentals/ICY: (06-21923)/(06-21980)
Databases
2014/15
Week 11 (Wednesday)
Relational Algebra (part 3)
Shereen Fouad
Teaching Fellow
School of Computer Science
University of Birmingham, UK
Announcements
Lab session tomorrow to catch up with any of the exercise that you have
missed or to complete the practical requirements of assignment 9.
No lecture on Friday (week 11).
Today is the Last Lecture!!!
Overview
Outer Joins
Left
Right
Full
Outer Joins
Developed for the case where the user wants to keep all the tuples in
Relation 1, or all those in Relation 2, or all those in both relations in
the result of the JOIN, regardless of whether or not they have
matching tuples in the other relation.
So.
Returns rows matching the join condition
Also returns rows with unmatched attribute values for tables to be
joined
Three types (Left, Right and Full)
Left and right designate order in which tables are processed
AGENT)
Uses all the rows in the CUSTOMER table, by doing equijoin on AGENT_CODE
but also including NON-matching CUSTOMER rows.
AGENT)
Uses all the rows in the AGENT table, doing equijoin on AGENT_CODE but also
including NON-matching AGENT rows.
Would have the extra row of this table as well as the extra row of
the Left Outer Join table
Using all the rows in the AGENT and CUSTOMER tables, doing equijoin on
AGENT_CODE but also including NON-matching rows from each table.
= Union of Left Outer Join result and Right Outer Join result.
list of all employee names as well as the name of the departments they manage if
they happen to manage a department; if they do not manage one, we can indicate it
with a NULL value
list of all employee names as well as the name of the departments they manage if
they happen to manage a department; if they do not manage one, we can indicate it
with a NULL value
Division
Goal: Produce the tuples in one relation, r, that match all tuples in
another relation, s
r (A1, An, B1, Bm)
s (B1 Bm)
r/s, with attributes A1, An, is the set of all tuples <a> such that for every
tuple <b> in s, <a,b> is in r
The only value of LOC that is associated in T with both values A and B of
CODE is 5.
Division - Example
Student_Records (StudId, CrsCode, Semester, Grade)
Teaching (ProfId, CrsCode, Semester)
List the Ids of students who have passed all courses that were taught
in summer 2013
Numerator: StudId and CrsCode for every course passed by every
student
StudId, CrsCode (Grade F (Student_Records ) )
Result is numerator/denominator
References
Source of images in this lecture:
Database Principles: Fundamentals of Design, Implementation and
Management, by Stephen Morris, Peter Rob, Carlos Coronel
Fundamentals of Database Systems by Ramez Elmasri, Shamkant B. Navathe
THANK YOU
GOOD LUCK