Professional Documents
Culture Documents
The Relational
Model & Relational
Database
Constraints
Chapter 3
Fall 2014
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (Coronel et al.)
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
Review
Database Users
Define different types of database users.
Professional Users:
Database Administrators
Database Designers
System Analysts
Application Programmers
End Users
Casual
Parametric
Sophisticated
Standalone
Review
Advantages of DBMS
Controlling redundancy
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
Review
Data Models
What is a data model?
A set of concepts to describe the structure of a database, and certain
constraints that the database should follow
Attribute
Relationship
5
Review
Representational Data Models
Object
XML
Network
Hierarchical
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
Review
Terminologies
What is DDL?
Data Definition Language: language used to define database schemas
What is DML?
Data Manipulation Language: language used to manipulate (retrieve,
insert, delete, and modify data)
Relational Data
Model Concepts
Chapter 3
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
Column
Each column has a column header
Gives some meaning of the data items in that column
In formal model, column header is called an attribute name (or
simply an attribute)
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
10
11
Example
PRODUCTS (UPC, Title, Price, Quantity)
PRODUCTS is the relation name
Defined over four attributes: UPC, title, price and quantity
Domain
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
12
Tuple
A tuple is an ordered set of values t = <v1, v2, , vn>
Each value vi, 1 , ( )
( )
Example
[?] == X
)
The Cartesian product specifies all possible combinations of
values from underlying domains
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
15
Example 1
Formal Definition
Let R(A1, A2) be a relation schema
Let dom(A1) = {1, 2, 3}
Let dom(A2) = {a, b, c}
possible combinations
is all
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
16
Example 2
Formal Definition
Assume we have the following sets:
| = 2 x 2 x 2 = 8
= {
Example 2
Formal Definition
Now there could be some subset out of the 8 pairs that we
only need (relation state)
The relation schema R(Name, Country, Course)
Let us assume the subset
{ (John, USA, MATH), (Joanna, Canada, CSCI) }
which is a subset of the Cartesian product that reflects only valid tuples
that represent a particular state of the real world
COUNTRY
COURSE
John
USA
MATH
Joanna
Canada
CSCI
18
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
Example 2
Formal Definition
Now there could be some subset out of the 8 pairs that we
only need (relation state)
Attributes
COUNTRY
USA
COURSE
ENGR
Joanna
Canada
CSCI
Tuples
Cardinality
Relation
NAME
John
Degree
19
Definition Summary
20
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
10
Example
A relation STUDENT
21
Characteristics of Relations
1
22
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
11
Characteristics of Relations
2
We will consider the attributes in R(A1, A2, ...,An) and the values in
t=<v1, v2, ..., vn> to be ordered
23
Characteristics of Relations
2
Example:
attendee(id, givenName, surname, company, dateOfBirth)
t = <10483, John, Doe, IBM, 1978-11-05>
t[id] = 10483, t[givenName] = John, t[surname] = Doe,
etc
t.id = 10483, t.givenName = John, t.surname = Doe, etc
t = { <id, 10483>, <givenName, John>, <surname, Doe>,
<company, IBM>, <dateOfBirth, 1978-11-05> }
24
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
12
Characteristics of Relations
3
Characteristics of Relations
3
25
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
13
Characteristics of Relations
4
27
Characteristics of Relations
4
28
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
14
30
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
15
31
32
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
16
The code for each classroom (AA for DWE 1501) is posted near the podium at the front
of the class. When a clicker is turned off it forgets any changes in frequency and the
clicker frequency is again AA when the clicker is turned on.
B:
Arts
C:
Environment
D:
Mathematics
E:
Science or Engineering
34
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
17
B:
C:
D:
E:
35
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw Hill, Cengage Learning
Slides adapted and modified from Fundamentals of Database Systems (5/6) (Elmasri et al.),
Database System Concepts (5/6) (Silberschatz et al.), Database Systems (9/10) (Coronel et al.)
18