Professional Documents
Culture Documents
Textbook: 7.5-7.11
Review
The Entity Relationship data model
Entities and attributes
Key attributes (candidate and primary keys)
Relationships
Participation and cardinality constraints
Attributes
Simple
Composite
Single-valued
Multivalued
Derived
For any attribute there is a set of possible values
Relationship degree
UNARY
between instances from one entity set
BINARY
between instances from two entity sets
TERNARY
between instances from three entity set
N-ARY
among entities from more than three entity sets
Participation
Some courses are not
students
Dave
courses
takes
2002ICT
Ken
Lisa
2506ICT
1234ICT
3502ICT
Participation constraints
Every student takes
total participation of
partial participation of
Student in Take
Course in Take
Cardinality
Measures how many instances of entity set B can be
students
Dave
Ken
John
Lisa
Tom
schools
belongs to
ICT
ENG
CHE
PHY
Cardinality constraints
Employee
has
Spouse
Customer
1
(0,M)
places
N
(1,1)
Student
M
(1:M)
enrolls
N
(0:N) Subject
Order
students
Dave
Ken
John
Lisa
Tom
schools
belongs to
ICT
ENG
CHE
PHY
Some notes
ERD design is subjective, there can be more than one
Overview
Weak entity types,
weak entity
identifying entity
identifying relationship
Constraint on higher order relationship types
Roles
Attributes of relationship types
Generalization and specialization
Depends
on
Name
Dependent
DName
partial key
Primary key partially or totally derived from identifying/
owner entity
E.g., the primary key of Dependent is {SSN, DName}
Need an identifying
relationship
Must be total
participation
Must be 1
Employee
SSN
Weak entity
Depends
on
Name
Dependent
DName
partial key
s1
p1
proj1
s2
p1
proj2
s1
p1
p1
proj1
s2
p1
p1
proj2
(0,1)
Supplies
(0,N)
Part
(1,N)
Project
(0,1)
Supplies
(0,N)
Part
(1,N)
Project
(0,1)
Supplies
(0,N)
Part
(1,N)
Project
Alternatives
For each course in each school, there are a unique
teaches
School
M
Course
A course in a school uniquely identify a teacher and a
textbook.
Supplier
(0,1)
Supplies
(0,N)
Part
(1,N)
Project
(0,1)
(1,1)
Supplies
(1,N)
(1,1)
Project
(1,1)
(0,N)
Part
Supplies becomes an entity (think of it as a supply
contract)
The PK of Supplies is the combination of PKs of
Supplier, Part, and Project.
(0,1)
Ha
Ha
Supply
s (1,1)
s
(1,1)
(1,N)
Project
(1,1)
Ha
s
(0,N)
Part
Supply is a weak entity type, with the owner entity type
Roles
Unary relation: Employee supervises Employee
Who supervises whom?
E.g. John Supervises Paul and Mary
Role name
Employee
(0,1)
(0,N)
Supervisor
Supervises
Supervisee
Supplier
(0,1)
Supplies
(0,N)
Part
(1,N)
Project
Understanding ER diagram
subclasses of staff
Overseas student, local student, postgraduate student,
undergraduate student, research student, coursework
student are all students
Subclass
Class
Address
Name
SSN
Staff
Address
Name
SSN
Manager
Level
Inheritance
Attributes SSN, Name, Address are inherited from
Staff
Address
Name
Staff
SSN
specialization
generalization
Manager
Level
Alternative notation
Address
Name
SSN
Staff
Manager
Level
Derived type
Attributes SSN, Name, Address are inherited from
Staff
Address
Name
SSN
Staff
Address = Brisbane
Local
Staff
Staff
Overlapping
subclasses
represented by o
Total participation by
double line
Disjoint
subclasses by d
Reservist
Manager
Engineer
Full-time
Part-time
Others
Salesman
Staff
Staff
Single line means
partial generalization
Technician
Salesman
Full-time
Staff
Double line means
total generalization
Full-time
Part-time
Staff
Overlapping specialization
Engineer
Manager
Staff
Staff
o
Manager
o stands for
overlapping
Engineer
Summary
Weak Entity types,
Constraint on higher order relationship types
Roles
Attributes of relationship types
Enhanced ER
Generalization and specialization hierarchies