Database Management Systems (BCSC-1003)
Topic: E–R Diagrams
E–R DIAGRAM
• E–R diagram stands for Entity Relationship Diagram.
• Entity–relationship modeling was developed for database and design by Peter Chen in
1976.
• An E–R diagram shows the relationship among entity sets.
• An entity set is a group of similar entities and these entities can have attributes.
• In terms of DBMS, an entity is a table.
• By showing relationship among tables and their attributes, E–R diagram shows the
complete logical structure of a database.
INTRODUCTION OF E–R
MODEL
ER Model is used to model the logical view of the system from data perspective which
consists of these components:
Entity, Entity Type, Entity Set:
• An Entity may be an object with a physical existence – a particular person, car, house, or
employee – or it may be an object with a conceptual existence – a company, a job, or a
university course.
• An Entity is an object of Entity Type and set of all entities is called as entity set. e.g.; E1 is
an entity having Entity Type Student and set of all students is called Entity Set. In ER
diagram, Entity Type is represented as:
INTRODUCTION OF E–R
MODEL
Attribute:
• Attributes are the properties which define the entity type. For example, Roll_No,
Name, DOB, Age, Address, Mobile_No are the attributes which defines entity type
Student. In ER diagram, attribute is represented by an oval.
INTRODUCTION OF E–R
MODEL
1. Key Attribute –
The attribute which uniquely identifies each entity in the entity set is called key
attribute. For example, Roll_No will be unique for each student. In ER diagram, key
attribute is represented by an oval with underlying lines.
INTRODUCTION OF E–R
MODEL
2. Composite Attribute –
An attribute composed of many other attribute is called as composite attribute. For
example, Address attribute of student Entity type consists of Street, City, State, and
Country. In ER diagram, composite attribute is represented by an oval comprising of
ovals.
INTRODUCTION OF E–R
MODEL
3. Multivalued Attribute –
An attribute consisting more than one value for a given entity. For example,
Phone_No (can be more than one for a given student). In ER diagram, multivalued
attribute is represented by double oval.
INTRODUCTION OF E–R
MODEL
4. Derived Attribute –
An attribute which can be derived from other attributes of the entity type is known as
derived attribute. e.g.; Age (can be derived from DOB). In ER diagram, derived
attribute is represented by dashed oval.
INTRODUCTION OF E–R
MODEL
The complete entity type Student with its attributes can be represented as:
INTRODUCTION OF E–R
MODEL
Relationship Type and Relationship Set:
A relationship type represents the association between entity types. For example,
‘Enrolled in’ is a relationship type that exists between entity type Student and
Course. In ER diagram, relationship type is represented by a diamond and
connecting the entities with lines.
INTRODUCTION OF E–R
MODEL
A set of relationships of same type is known as relationship set. The following
relationship set depicts S1 is enrolled in C2, S2 is enrolled in C1 and S3 is enrolled
in C3.
INTRODUCTION OF E–R
MODEL
Degree of a relationship set:
The number of different entity sets participating in a relationship set is called as
degree of a relationship set.
1. Unary Relationship –
When there is only ONE entity set participating in a relation, the relationship is
called as unary relationship. For example, one person is married to only one person.
INTRODUCTION OF E–R
MODEL
2. Binary Relationship –
When there are TWO entities set participating in a relation, the relationship is called
as binary relationship. For example, Student is enrolled in Course.
INTRODUCTION OF E–R
MODEL
3. n-ary Relationship –
When there are n entities set participating in a relation, the relationship is called as n-ary
relationship.
Cardinality:
The number of times an entity of an entity set participates in a relationship set is known as
cardinality. Cardinality can be of different types as:
A. One to One Relationship
B. One to Many Relationship
C. Many to One Relationship &
D. Many to Many Relationship
INTRODUCTION OF E–R
MODEL
A. One to One Relationship – When a single instance of an entity is associated
with a single instance of another entity then it is called one to one relationship. For
example, a person has only one passport and a passport is given to one person.
B. One to Many Relationship – When a single instance of an entity is associated
with more than one instances of another entity then it is called one to many
relationship. For example – a customer can place many orders but a order cannot be
placed by many customers.
INTRODUCTION OF E–R
MODEL
C. Many to One Relationship – When more than one instances of an entity is
associated with a single instance of another entity then it is called many to one
relationship. For example – many students can study in a single college but a student
cannot study in many colleges at the same time.
D. Many to Many Relationship – When more than one instances of an entity is
associated with more than one instances of another entity then it is called many to
many relationship. For example, a student can be assigned to many projects and a
project can be assigned to many students.
INTRODUCTION OF E–R
MODEL
Participation Constraint:
Participation Constraint is applied on the entity participating in the relationship set.
Total Participation – Each entity in the entity set must participate in the relationship. If
each student must enroll in a course, the participation of student will be total. Total
participation is shown by double line in ER diagram.
Partial Participation – The entity in the entity set may or may NOT participate in the
relationship. If some courses are not enrolled by any of the student, the participation of
course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set having total
participation and Course Entity set having partial participation.
INTRODUCTION OF E–R
MODEL
Weak Entity Type and Identifying Relationship:
As discussed before, an entity type has a key attribute which uniquely identifies each entity
in the entity set. But there exists some entity type for which key attribute can’t be defined.
These are called Weak Entity type.
For example, A company may store the information of dependents (Parents, Children,
Spouse) of an Employee. But the dependents don’t have existence without the employee.
So Dependent will be weak entity type and Employee will be Identifying Entity type for
Dependent.
A weak entity type is represented by a double rectangle. The participation of weak entity
type is always total. The relationship between weak entity type and its identifying strong
entity type is called identifying relationship and it is represented by double diamond.
E–R DIAGRAM FOR ONLINE
SHOPPING SYSTEM
E–R DIAGRAM FOR ONLINE
SHOPPING SYSTEM
E–R DIAGRAM FOR ONLINE
SHOPPING SYSTEM
E–R DIAGRAM FOR ONLINE
SHOPPING SYSTEM
E–R DIAGRAM FOR ONLINE
SHOPPING SYSTEM
REFERENCES
• Korth, Silbertz and Sudarshan (1998), “Database Concepts”, 4th
Edition, TMH.
• Elmasri and Navathe (2010), “Fundamentals of Database
Systems”, 5th Edition, Addision Wesley.
• Date C J,” An Introduction to Database Systems”, 8th Edition,
Addision Wesley.
• M. Tamer Oezsu, Patrick Valduriez (2011). “Principles of
Distributed Database Systems”, 2nd Edition, Prentice Hall.