CS 480: Database Systems
Lecture 4
January 23, 2013
Exercise ER-Diagram
• Database System for an Airline to be used for:
– Booking Flights
– Managing Flights, Crew Members, and their
Planes
• Construct an ER-diagram for this Airline
Enterprise.
Exercise ER-Diagram #2
• Construct an ER-Diagram for a Course
Registration System.
THE RELATIONAL MODEL
Relational Model
• Proposed in 1970 by E.F. Codd
– “A Relational Model of Data for Large Shared Data
Banks”, Communications of the ACM 13(6)
• Simplicity compared to previous models no
longer in use (network model or hierarchical
model)
• ER-diagrams good for modeling and visualizing
• Relational model brings us closer to the data
representation.
Relational Model
• Every node (sets) in ER-diagram gets a
relation.
Weight
Supplier
Id
Price
Color
SUPPLIER
PART
SUPPLIES
Part Id
Supp. Name
City
Part Name
Relational model
• Every node (sets) in ER-diagram gets a
relation.
• Supplier(supplier-id,supplier-name,city)
• Part(part-id,part-name,color,weight)
• Supplies(supplier-id,part-id,price)
Relational Database Instance
Supplier:
Supplier-id
Suppliername
City
123
ACME
Chicago
234
BBQ Inc.
345
456
Supplies:
Part:
Part-id
Partname
Color
Weight
New York
12
Nut
Gray
12
COLE
London
15
Bolt
Orange
17
Dave’s
Chicago
5
Screw
Blue
17
Supplier-id
Part-id
Price
123
12
1
234
15
2
123
15
1.5
345
5
1
345
15
1.25
Attributes
• An attribute is a symbolic name
– eg. Supplier-name, part-id, price
• With each attribute is associated a domain
Attributes
• An attribute is a symbolic name
– eg. Supplier-name, part-id, price
• With each attribute is associated a domain
• What are domains for the following attributes?
–
–
–
–
–
Social-Security #
Birthdate
Price
Gender
Age
Relation Scheme
• A relation scheme, R, is a set of attributes
{A1,A2,…, An}and is denoted by:
R(A1,A2,…,An)
• Ex:
– Supplier(supplier-id,supplier-name,city)
– Supplier(supplier-name,supplier-id,city)
– Both are the same.
– No duplicates and no order.
Tuples
• Def: A tuple on a relation scheme R is an
assignment of values, one to each attribute of
R.
• The value of attribute Ai is taken from its
domain.
Part-id
Partname
Color
Weight
12
Nut
Gray
12
tuple
15
Bolt
Orange
17
tuple
5
Screw
Blue
17
tuple
Relation
• A relation on R, r(R), is a set of tuples on R.
• Relations can be looked at as tables.
Supplier-id
Suppliername
City
Part-id
Partname
Color
Weight
123
ACME
Chicago
12
Nut
Gray
12
234
BBQ Inc.
New York
15
Bolt
Orange
17
345
COLE
London
5
Screw
Blue
17
456
Dave’s
Chicago
Relational Model
• Set of relation schemes forms the relational
schema
– eg. Supplier database
• Supplier(supplier-id,supplier-name,city)
• Part(part-id,part-name,color,weight)
• Supplies(supplier-id,part-id,price)
Relational Database
• Set of relations forms the relational database.
Supplier-id
Part-id
Partname
Color
Weight
12
Nut
Gray
12
15
Bolt
Orange
17
5
Screw
Blue
17
Suppliername
City
123
ACME
Chicago
234
BBQ Inc.
New York
345
COLE
London
Supplier-id
Part-id
Price
456
Dave’s
Chicago
123
12
1
234
15
2
123
15
1.5
345
5
1
345
15
1.25
Keys
• Same concept introduced for ER model applies in
the relational model.
• Previous def: The key of an entity set E is a
minimal subset of the attributes of E that
uniquely indentifies an entity in the set.
Keys
• Same concept introduced for ER model applies in
the relational model.
• Previous def: The key of an entity set E is a
minimal subset of the attributes of E that
uniquely indentifies an entity in the set.
• Def: The key of a relation R is a minimal subset of
the attributes of R that uniquely indentifies a
tuple of the relation.
• This subset of attributes adequately distinguishes
between elements of the relation (tuples).
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Supplier-id
Suppliername
City
123
ACME
Chicago
234
BBQ Inc.
New York
345
COLE
London
456
Dave’s
Chicago
Is {city} a valid key?
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Supplier-id
Suppliername
City
123
ACME
Chicago
234
BBQ Inc.
New York
345
COLE
London
456
Dave’s
Chicago
Is {supplier-id,city}
a valid key?
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Supplier-id
Suppliername
City
123
ACME
Chicago
234
BBQ Inc.
New York
345
COLE
London
456
Dave’s
Chicago
{supplier-id} is the key
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Does every relation have a key?
Keys in the Relational Model
• Let K be the key of R.
1. No relation instance of R is allowed to have two
tuples that are equal on K.
2. No proper subset of K satisfies condition 1.
Does every relation have a key?
Relation is a set of tuples so yes. At worst, every
attribute will form part of the key.
Data Manipulation Languages (DML)
• Language for accessing and manipulating the
data.
• Languages for expressing queries.
• Queries – requests for information from the
database.
• Ex.
– Retrieve the supplier names for suppliers located in
London.
– Retrieve the parts that are shipped by suppliers in
Paris (involves 2 relations).
© Copyright 2026 Paperzz