Professional Documents
Culture Documents
DB Lec 7
DB Lec 7
Week 05
Understanding of Super Key, Candidate Key,
Primary Key, Composite Key
I'll take example of an Employee table:
Employee (Employee ID, FullName, SSN, DeptID)
Relationship
– When an attribute of one entity type refers to
another entity type
– Represent references as relationships not attributes
Relationships are the connections and interactions
between the entities instances, e.g., Program and
Student ETs are linked
Relationship Types, Sets, and Instances
Relationship type R among n entity types E1,
E2, ..., En
– Defines a set of associations among entities from
these entity types
– Relationship instances ri
– Each ri associates n individual entities (e1, e2, ..., en)
– Each entity ej in ri is a member of entity set Ej
– Relationship instances
Relationship set: set of all relationships (r1, r2….rn)
Naming Relationships
Up to you
If there is no proper name of the association in the
system then participants’ names of abbreviations
are used
STUDENT and CLASS have ENROLL
relationship
However, it can also be named as STD_CLS
Naming Relationships
Choose names that convey meanings attached
to different relationship
Nouns give rise to entity type names, Verbs
indicate names of relationship types
Choose binary relationship names to make ER
diagram readable from left to right and from
top to bottom
Symbol for Relationships
DEPT EMP
STD BOOK
Relationships Types
Binary Relationship
– 2 Entities
Ternary Relationship
– 3 Entities
Unary Relationship
– 1 Entity
Binary Relationship Example
STD COURSE
STD BOOK
PROJ EMP
Attributes of the Relationships
The relationships can have their descriptive
attributes
Where to place
GRADE
STD COURSE
Ternary Relationships
One that involves three entity types
STUDENT-CLASS-FACULTY
Instances in ordered triples
Example {(S1013, MCS4, Adnan), (S1023, MCS3,
Fasih)}
STD COURSE
PROJ EMP
FACULTY
SKILL
Unary Relationship
An ET linked with itself, also called recursive
relationship
Example Roommate, where STUDENT is linked
with STUDENT
Unary Relationship Examples
STD ROOMMATE
EMP CHAIR-
PERSON
EMP SPOUSE
Constraints on Binary Relationship Types
One to one
One to many
Many to one
Many to many
Types of Cardinalities
One to one
DEPT
Chair
Person
Many to many
EMP PROJ
PROJ EMP
Cardinality Example
STD BOOK
EMP PROJ
STD COURSE
STD HOBBY
Weak Entity Types