Database Management System
Entity Relationship
Model
Dr. H K Chavan
Agenda
● Prerequisites and Course Outline
● Database System Concepts and Architecture
● Entity Relationship Model
● Conceptual Modelling of a Database, Entity Relationship
(ER) Model, Entity Type, Entity Sets, Attributes and Keys,
Relationship Types, Relationship Sets.
● Weak Entity Types, Generalization, Specialization and
Aggregation, Extended Entity-Relationship (EER) Model.
● Relational Model & Relational Algebra
● Structured Query Language (SQL) & Indexing
● Relational Database Design
● Transactions Management, Concurrency and Recovery
2
RECAP
• A Key for an entity is a set of attributes that suffice to
distinguish entities from each other
• Key = set of attributes identifying individual entities or relationships
• Super key, Candidate key, Primary key
• Weak Entity Types
3
Building an ER Model
• The requirements specification is the first step to any
design; it captures the ‘what’ of the business
environment.
• Documents the “ business rules” i.e the constraints that
will apply to your database.
• The ER model must capture the participating entities as
well as these rules.
• Summary • Additional Details:
• Intuitive diagram-based • Relationship of
representation domain
knowledge, data properties etc…cardinalities
• Two key concepts: • Keys
• Entities • Participation
• Relationships Constraints
4
• …
Building an ER Model
• Step 1 Identify Entities
• Step 2 Work out relationships
• Step 3 Identify Attributes
• Step 4 Identify optionality
• Step 5 Identify KEY attributes
Resolve any assumptions
5
Building an ER Model : Example
• Design an E-R diagram for keeping track of the exploits of
your favorite sports team. You should store the matches
played, the scores in each match, the players in each
match and individual players statistics for each match.
• Summery statistics
Design an E-R diagramshould be track
for keeping modeled
of theasexploits
derivedof
attribute.
your favorite sports team. You should store the matches
played, the scores in each match, the players in each
match and individual players statistics for each match.
• Summery statistics
Design an E-R diagramshould be track
for keeping modeled
of theasexploits
derivedof
attribute.
your favorite sports team. You should store the matches
played, the scores in each match, the players in each
match and individual players statistics for each match.
Summery statistics should be modeled as derived
6
Building an ER Model : Example
• Design an E-R diagram for keeping track of the exploits of
your favorite sports team. You should store the matches
played, the scores in each match, the players in each
match and individual players statistics for each match.
Summery statistics should be modeled as derived
attribute.
MATCH PLAYER
7
ER Example
• Construct an ER diagram for car insurance company that has a set
of customers each of whom owns one or more cars. Each car has
associated with it zero to any number of recorded accidents
8
PROBLEM with ER notation
• The entity relationship model in its original form did not
support the specialization/ generalization abstractions
• Why?
• Databases for:
• Engineering design and manufacturing (CAD/CAM),
Telecommunications, Complex Software Systems, and
Geographic Information Systems (GIS)
• These types of databases have more complex requirements
than do the more traditional applications
• This led to the development of additional semantic data
modeling concepts that were incorporated into conceptual
(ER) data model.
• Features that have been proposed for semantic data models,
and show how the ER model can be enhanced to include
9
Enhanced Entity-Relationship (EER) Model
10
Enhanced Entity-Relationship (EER) Model
11
Enhanced Entity-Relationship (EER) Model
12
Enhanced Entity-Relationship (EER) Model
13
Enhanced Entity-Relationship (EER)
Model
• The relationship between a superclass and any one of its
subclasses is a Superclass /subclass or supertype/subtype
or simply class/subclass relationship
• Example: EMPLOYEE /SECRETARY and EMPLOYEE
/TECHNICIAN are two class/subclass relationships.
• Note:
• A member entity of the subclass represents the same
real-world entity as some member of the superclass;
• Example: A SECRETARY entity ‘Jimi’ is also the
EMPLOYEE ‘Jimi.’
• Hence, the subclass member is the same as the entity
in the superclass, but in a distinct specific role.
• When we implement a superclass/subclass relationship in
the database system, however,
14 we may represent a
Enhanced Entity-Relationship (EER) Model
15
Enhanced Entity-Relationship (EER) Model
16
Specialization
• Consider entity person:
• Attributes: name, street, city
• Further classification:
• Customer
• Additional attributes: customer-id,
credit-rating
• Employee
• Additional attributes: employee-
id, salary
• Note similarities to object-oriented
programming 17
Specialization
18
Specialization
19
Specialization
20
Specialization
• The second reason for using subclasses is that some
relationship types may be participated in only by entities
that are members of the subclass.
• For example, if only HOURLY_EMPLOYEES can belong
to a trade union, we can represent that fact by
creating the subclass HOURLY_EMPLOYEE of
EMPLOYEE and relating the subclass to an entity type
TRADE_UNION via the BELONGS_TO relationship type.
• Summary: Specialization process allows us to do the
following
• Define a set of subclasses of an entity type
• Establish additional specific attributes with each
subclass 21
Generalization
• We can think of a reverse process of abstraction in which we
suppress the differences among several entity types, identify
their common features, and generalize them into a single
superclass of which the original entity types are special
subclasses.
• For example, consider the entity types CAR and TRUCK
22
Constraints and Characteristics
of Specialization and Generalization
• In some specializations we can
determine exactly the entities
that will become members of
each subclass by placing a
condition on the value of some
attribute of the superclass.
Such subclasses are called
predicate-defined (or condition-
defined) subclasses.
• For example, if the EMPLOYEE
entity type has an attribute
Job_type, we can specify the
condition of membership in the
SECRETARY subclass by the
23
Constraints and Characteristics
of Specialization and Generalization
• Two other constraints of a specialization.
• The first is the disjointness (or disjointedness) constraint,
which specifies that the subclasses of the specialization must
be disjoint.
• This means that an entity can be a member of at most one of
the subclasses of the specialization. A specialization that is
attribute-defined implies the disjointness constraint (if the
attribute used to define the membership predicate is single-
valued).
• The d in the circle stands for disjoint
• If the subclasses are not constrained to be disjoint, their
sets of entities may be overlapping; that is, the same
(real-world) entity may be 24a member of more than one
Constraints and Characteristics
of Specialization and Generalization
• The second constraint on specialization is called the
completeness (or totalness) constraint, which may be total or
partial.
• A total specialization constraint specifies that every entity in the
superclass must be a member of at least one subclass in the
specialization.
• For example, if every EMPLOYEE must be either an
HOURLY_EMPLOYEE or a SALARIED_EMPLOYEE
• It is shown in EER diagrams by using a double line to connect the
superclass to the circle.
• A single line is used to display a partial specialization, which
allows an entity not to belong to any of the subclasses.
• Notice that the disjointness and completeness constraints are
independent. Hence, we have the following four possible
constraints on specialization: 25
Building an ER Model
• Step 1 Identify Entities
• Step 2 Work out relationships
• Step 3 Identify Attributes
• Step 4 Identify optionality
• Step 5 Identify KEY attributes
Resolve any assumptions
26
Building an ER Model
• Draw an ER diagram for a School Management
System based on the following information.
• You have been asked to implement a database for a
school management system (SMS). This primarily consists
of maintaining students' information like name, address,
date of birth, roll number, deparment, and so on. Details
about the school to be stored includes school's name,
location. Although it is unlikely that there would be two
schools at the same place with same name, but our SMS
would like to accomodate this possibility.
• Faculty members works in the school. They teaches the
students. A faculty member normally teaches multiple
students at a http://vlabs.iitkgp.ernet.in/se/4/exercise/
time. Also, he can teach multiple courses to
the students. 27
Building an ER Model : Example
• A college library holds books for its members to borrow.
Each book may be written by more than one author. Any
one author may have written several books. If no copies
of a wanted book are currently in stock, a member may
make a reservation for the title until it is available. If
books are not returned on time a fine is imposed and if the
fine is not paid the member is barred from loaning any
• other
A college library
books holds
until the books
fine for its members to borrow.
is paid.
Each book may be written by more than one author. Any
one author may have written several books. If no copies
of a wanted book are currently in stock, a member may
make a reservation for the title until it is available. If
books are not returned on time a fine is imposed and if the
fine is not paid the member 28 is barred from loaning any
Building an ER Model : Example
• A college library holds books for its members to borrow.
Each book may be written by more than one author. Any
one author may have written several books. If no copies
of a wanted book are currently in stock, a member may
make a reservation for the title until it is available. If
books are not returned on time a fine is imposed and if the
fine is not paid the member is barred from loaning any
• A college library holds books for its members to borrow.
other books until the fine is paid.
Each book may be written by more than one author. Any
one author may have written several books. If no copies
of a wanted book are currently in stock, a member may
make a reservation for the title until it is available. If
books are not returned on time a fine is imposed and if the
fine is not paid the member 29
is barred from loaning any
Building an ER Model : Example
Title
Member Book Author
30
Building an ER Model : Example
31
Building an ER Model : Example
32
“
THANKS FOR LISTENING
33