DB Lec 10
DB Lec 10
Database Systems
Lecture 10
Database Management S
ystems
Today’s agenda
• Relationships
▫ Types, sets and instances
• Degree of relationship
• Recursive Relationship
• Constraints on Relationship Types
• Attributes of Relationship Types
3
Database Management S
ystems
Relationships
• A relationship relates two or more distinct entities with
a specific meaning.
▫ For example, EMPLOYEE John Smith works on the
ProductX PROJECT, OR
▫ EMPLOYEE Franklin Wong manages the Research
DEPARTMENT.
Database Management S
ystems
• Each of the entity types E1, E2, ... , En is said to participate in the relationship
type R; similarly, each of the individual entities e1, e2, ... , en is said to
participate in the relationship instance ri = (e1, e2, ..., en)
5
Database Management S
ystems
Database Management S
ystems
Degree of a Relationship
• Is the number of participating entity types
▫ The WORKS_FOR relationship is of degree two.
• A relationship type of degree two is called binary
• A relationship type of degree three is called
ternary
7
Database Management S
ystems
Database Management S
ystems
Role Name
• The role name signifies the role that a
participating entity from the entity type plays in
each relationship instance, and helps to explain
what the relationship means.
• For example, in the WORKS_FOR relationship
type, EMPLOYEE plays the role of employee or
worker and DEPARTMENT plays the role of
department or employer.
9
Database Management S
ystems
Recursive Relationship
• In some cases the same entity type participates
more than once in a relationship type in
different roles
• Such relationship types are called recursive
relationships
• The SUPERVISION relationship type relates an
employee to a supervisor, where both employee
and supervisor entities are members of the same
EMPLOYEE entity type.
10
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
Database Management S
ystems
DIAGRAM
NOTATION FOR ER
SCHEMAS