Entity-Relationship (E/R) Model
Entity-Relationship (E/R) Model
Entity-Relationship
(E/R) Model
Dr P Sreenivasa Kumar
Professor
CS&E Dept I I T Madras
Entities
§ Entity - a thing (animate or inanimate) of independent
physical or conceptual existence and distinguishable.
In the University database context, an individual
student, faculty member, a class room, a course
are entities.
1
26/01/20
Attributes
Each entity is described by a set of attributes/properties
that have associated values
student entity
§ StudName – name of the student.
§ RollNumber – the roll number of the student.
§ Sex – the gender of the student etc.
2
26/01/20
Fname Mname
Lname
Program
RollNumber
StudName
Student AdmissionYear
Sex
Age EmailAddress
DateOfBirth
Domains of Attributes
Each attribute takes values from a set called its domain
For instance, studentAge – {17,18, …, 55}
HomeAddress – character strings of length 35
Domain of composite attributes –
cross product of domains of component attributes
Domain of multi-valued attributes –
set of subsets of values from the basic domain
3
26/01/20
Relationships
Degree of a relationship
• Degree : the number of participating entities.
• Degree 2: binary
• Degree 3: ternary
• Degree n: n-ary
A B
R
4
26/01/20
M N
E1 R E2
Cardinality Ratios
• One-to-one: An E1 entity may be associated with at
most one E2 entity and similarly
an E2 entity may be associated with at
most one E1 entity.
• One-to-many: An E1 entity may be associated with
many E2 entities whereas an E2 entity may
be associated with at most one E1 entity.
• Many-to-one: An E2 entity may be associated with
many E1 entities whereas an E1 entity may
be associated with at most one E2 entity.
• Many-to-many: Many E1 entities may be associated with a
single E2 entity and a single E1 entity
may be associated with many E2 entities.
One-to-many
E1 E2 E1 One-to-one E2
Many-to-one
E1 E2 E1 Many-to-many E2
5
26/01/20
Address
HostelName
Name
RoomNo
1 1 Hostel
RollNo Student ResidesIn Room
Address
Name Location
Name Phone
N 1
Sex Professor belongsTo Department
(many-to-one)
Address
Name RoomNo
Name Phone
1 N
guides Student
Sex Professor
Name RollNo
Name
CourseId
Student enrolls Course
M N
Address
Credits
Value Duration
Address
Start End
Date Date
6
26/01/20
Participation Constraints
• An entity set may participate in a relation either totally or
partially.
• Total participation: Every entity in the set is involved in
some association (or tuple) of the relationship.
• Partial participation: Not all entities in the set are involved
in association (or tuples) of the relationship.
Notation:
E1 R E2
total partial
Name Location
Name Phone
N 1
Sex Professor belongsTo Department
(many-to-one)
Address
Name RoomNo
Name Phone
1 N Student
Sex Professor guides
Address Address
one-to-many
Structural Constraints
• Cardinality Ratio and Participation Constraints are together
called Structural Constraints.
• They are called constraints as the data must satisfy them to be
consistent with the requirements.
• Min-Max notation: pair of numbers (m,n) placed on the line
connecting an entity to the relationship.
• m: the minimum number of times a particular entity must
appear in the relationship tuples at any point of time
• 0 – partial participation
• ≥ 1 – total participation
• n: similarly, the maximum number of times a particular entity
can appear in the relationship tuples at any point of time
7
26/01/20
is equivalent to
(1,1) (0,N)
E1 R E2
Many-to-one
E1 E2
M N
Student enrolls Course
Grade
N 1
Professor belongsTo Department
joinDate
M N
Professor worksFor SponsoredProject
percentTime
8
26/01/20
Course
course
Role Names
Prof P Sreenivasa Kumar 25
Department of CS&E, IITM
Double wall
S R W box
Always total
Owner entity
Identifying relationship
Prof P Sreenivasa Kumar 26
Department of CS&E, IITM
9
26/01/20
10
26/01/20
Entities - Student
HNo Street
City
HostelName
EmailId PIN
Address
RoomNo
RollNo ess
ddr
alA
Loc
Name Student
DateOfBirth
Age
Sex
Location Credits
Name CourseID Name
Phone
HOD
Department Course
DeptNo
ProfID Amount
PhoneNumber
StartDate EndDate
ProjectId
Section
Timing
SectionID ClassRoom
11
26/01/20
N 1
Student belongs Department
M
To
1
1
enrolls works
ers For
N off
N
N
1
Course 1 Professor
M N M
hasSection teaches
prerequisite works
Of
N
On
N N
Section Project
Design Choices:
12
26/01/20
Ternary Relationships
Relationship instance (c, p, j) in supply indicates that
company c supplies a component p that is made use of by the project j
canSupply
ser s
ve
s use
Ternary Relationships
(c,p) in canSupply, (j,p) in uses, (c,j) in serves may not together imply (c,p,j) is
in supply. Whereas the other way round is of course true.
canSupply
ser s
ve
s use The binary
relationships
together do not
Example from Project convey the
Elmasri & Navathe same meaning
as supply
Fund. of DB Systems
Prof P Sreenivasa Kumar 38
Department of CS&E, IITM
13