Unit-1
Introduction to Database System
(Entity Relationship Model in DBMS)
Dr. Virendra Singh Kushwah
Senior Assistant Professor
School of Computing Science and Engineering
[email protected]Entity-Relationship Model
• Entity-Relationship (ER) Model is based on the notion of real-world entities
and relationships among them. While formulating real-world scenario into
the database model, the ER Model creates entity set, relationship set,
general attributes and constraints.
• ER Model is best used for the conceptual design of a database.
• ER Model is based on −
• Entities and their attributes.
• Relationships among entities.
• Entity − An entity in an ER Model is a real-world entity having properties called attributes. Every
attribute is defined by its set of values called domain. For example, in a school database, a student is
considered as an entity. Student has various attributes like name, age, class, etc.
• Relationship − The logical association among entities is called relationship. Relationships are
mapped with entities in various ways. Mapping cardinalities define the number of association
between two entities.
• Mapping cardinalities −
• one to one
• one to many
• many to one
• many to many
What is an Entity Relationship Diagram
(ER Diagram)?
• An ER 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 or attribute of a table in database, so
by showing relationship among tables and their attributes, ER diagram
shows the complete logical structure of a database. Lets have a look at a
simple ER diagram to understand this concept.
• Entity-Relationship Model or simply ER Model is a high-level data
model diagram. In this model, we represent the real-world problem in
the pictorial form to make it easy for the stakeholders to understand.
It is also very easy for the developers to understand the system by
just looking at the ER diagram.
• We use the ER diagram as a visual tool to represent an ER Model. ER
diagram has the following three components:
• Entities: Entity is a real-world thing. It can be a person, place, or even a
concept. Example: Teachers, Students, Course, Building, Department, etc.
are some of the entities of a School Management System.
• Attributes: An entity contains a real-world property called attribute. This is
the characteristics of that attribute. Example: The entity teacher has the
property like teacher id, salary, age, etc.
• Relationship: Relationship tells how two attributes are related. Example:
Teacher works for a department.
• This model captures the relationships between real-world entities
much like the network model, but it isn’t as directly tied to the
physical structure of the database. Instead, it’s often used for
designing a database conceptually.
• Here, the people, places, and things about which data points are
stored are referred to as entities, each of which has certain attributes
that together make up their domain. The cardinality, or relationships
between entities, are mapped as well.
• In the given diagram we have
two entities Student and
College and their relationship.
The relationship between
Student and College is many to
one as a college can have many
students however a student
cannot study in multiple
colleges at the same time.
Student entity has attributes
such as Stu_Id, Stu_Name &
Stu_Addr and College entity has
attributes such as Col_ID &
Col_Name.
1. Rectangle: Represents Entity sets.
2. Ellipses: Attributes
3. Diamonds: Relationship Set
4. Lines: They link attributes to Entity Sets
and Entity sets to Relationship Set
5. Double Ellipses: Multivalued Attributes
6. Dashed Ellipses: Derived Attributes
7. Double Rectangles: Weak Entity Sets
8. Double Lines: Total participation of an
entity in a relationship set
Components of a ER Diagram
1. Entity
• An entity is an object or component of data. An entity is represented as
rectangle in an ER diagram.
• For example: In the following ER diagram we have two entities Student
and College and these two entities have many to one relationship as many
students study in a single college. We will read more about relationships
later, for now focus on entities.
• Weak Entity:
• An entity that cannot be uniquely identified by its own attributes and relies
on the relationship with other entity is called weak entity. The weak entity is
represented by a double rectangle. For example – a bank account cannot be
uniquely identified without knowing the bank to which the account belongs,
so bank account is a weak entity.
2. Attribute
• An attribute describes the property of an entity. An attribute is
represented as Oval in an ER diagram. There are four types of
attributes:
• 1. Key attribute
• 2. Composite attribute
• 3. Multivalued attribute
• 4. Derived attribute
• 1. Key attribute:
• A key attribute can uniquely identify an entity from an entity set. For example,
student roll number can uniquely identify a student from a set of students. Key
attribute is represented by oval same as other attributes however the text of
key attribute is underlined.
• 2. Composite attribute:
• An attribute that is a combination of other attributes is known as composite
attribute. For example, In student entity, the student address is a composite
attribute as an address is composed of other attributes such as pin code,
state, country.
• 3. Multivalued attribute:
• An attribute that can hold multiple values is known as multivalued
attribute. It is represented with double ovals in an ER Diagram. For
example – A person can have more than one phone numbers so the
phone number attribute is multivalued.
• 4. Derived attribute:
• A derived attribute is one whose value is dynamic and derived from another
attribute. It is represented by dashed oval in an ER Diagram. For example –
Person age is a derived attribute as it changes over time and can be derived
from another attribute (Date of birth).
• E-R diagram with multivalued and derived attributes:
3. Relationship
• A relationship is represented by diamond shape in ER diagram, it
shows the relationship among entities. There are four types of
relationships:
• 1. One to One
• 2. One to Many
• 3. Many to One
• 4. Many to Many
• 1. 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.
• 2. 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.
• 3. 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.
• 4. 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 can be assigned to many projects and a project can be assigned
to many students.
Total Participation of an Entity set
• A Total participation of an entity set represents that each entity in entity set
must have at least one relationship in a relationship set. For example: In the
below diagram each college must have at-least one associated Student.
Features of ER Model
1. Graphical Representation for Better Understanding: It is very easy
and simple to understand so it can be used by the developers to
communicate with the stakeholders.
2. ER Diagram: ER diagram is used as a visual tool for representing the
model.
3. Database Design: This model helps the database designers to build
the database and is widely used in database design.
Advantages of ER Model
1. Simple: Conceptually ER Model is very easy to build. If we know the
relationship between the attributes and the entities we can easily
build the ER Diagram for the model.
2. Effective Communication Tool: This model is used widely by the
database designers for communicating their ideas.
3. Easy Conversion to any Model: This model maps well to the
relational model and can be easily converted relational model by
converting the ER model to the table. This model can also be
converted to any other model like network model, hierarchical
model etc.
Disadvantages of ER Model
1. No industry standard for notation: There is no industry standard
for developing an ER model. So one developer might use notations
which are not understood by other developers.
2. Hidden information: Some information might be lost or hidden in
the ER model. As it is a high-level view so there are chances that
some details of information might be hidden.