0% found this document useful (0 votes)
15 views

DBMS_Introduction of ER Model

database management system

Uploaded by

zerin22205101835
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

DBMS_Introduction of ER Model

database management system

Uploaded by

zerin22205101835
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Introduction of ER Model

Last Updated : 30 Aug, 2024

Peter Chen developed the ER diagram in 1976. The ER model was


created to provide a simple and understandable model for representing
the structure and logic of databases. It has since evolved into variations
such as the Enhanced ER Model and the Object Relationship Model

The Entity Relational Model is a model for identifying entities to be


represented in the database and representation of how those entities are
related. The ER data model specifies enterprise schema that represents
the overall logical structure of a database graphically.

The Entity Relationship Diagram explains the relationship among the


entities present in the database. ER models are used to model real-world
objects like a person, a car, or a company and the relation between
these real-world objects. In short, the ER Diagram is the structural
format of the database.

Why Use ER Diagrams In DBMS?

● ER diagrams represent the E-R model in a database, making


them easy to convert into relations (tables).
● ER diagrams provide the purpose of real-world modeling of
objects which makes them intently useful.
● ER diagrams require no technical knowledge and no hardware
support.
● These diagrams are very easy to understand and easy to create
even for a naive user.
● It gives a standard solution for visualizing the data logically.

Symbols Used in ER Model

ER Model is used to model the logical view of the system from a data
perspective which consists of these symbols:

● Rectangles: Rectangles represent Entities in the ER Model.


● Ellipses: Ellipses represent Attributes in the ER Model.
● Diamond: Diamonds represent Relationships among Entities.
● Lines: Lines represent attributes to entities and entity sets with
other relationship types.
● Double Ellipse: Double Ellipses represent Multi-Valued
Attributes.
● Double Rectangle: Double Rectangle represents a Weak Entity.

Symbols used in ER Diagram

Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among
Entities in a Database System.

Components of ER Diagram

What is Entity?

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.

What is Entity Set?

An Entity is an object of Entity Type and a set of all entities is called an


entity set. For Example, E1 is an entity having Entity Type Student and
the set of all students is called Entity Set. In ER diagram, Entity Type is
represented as:
Entity Set

We can represent the entity set in ER Diagram but can’t represent entity
in ER Diagram because entity is row and column in the relation and ER
Diagram is graphical representation of data.

Types of Entity

There are two types of entity:

1. Strong Entity

A Strong Entity is a type of entity that has a key Attribute. Strong Entity
does not depend on other Entity in the Schema. It has a primary key,
that helps in identifying it uniquely, and it is represented by a rectangle.
These are called Strong Entity Types.

2. Weak Entity

An Entity type has a key attribute that uniquely identifies each entity in
the entity set. But some entity type exists for which key attributes can’t
be defined. These are called Weak Entity types .

For Example, A company may store the information of dependents


(Parents, Children, Spouse) of an Employee. But the dependents can’t
exist without the employee. So Dependent will be a Weak Entity Type
and Employee will be Identifying Entity type for Dependent, which
means it is Strong Entity Type .

A weak entity type is represented by a Double Rectangle. The


participation of weak entity types is always total. The relationship
between the weak entity type and its identifying strong entity type is
called identifying relationship and it is represented by a double
diamond.

Strong Entity and Weak Entity

What is Attributes?
Attributes are the properties that define the entity type. For example,
Roll_No, Name, DOB, Age, Address, and Mobile_No are the attributes
that define entity type Student. In ER diagram, the attribute is
represented by an oval.

Attribute

Types of Attributes

1. Key Attribute

The attribute which uniquely identifies each entity in the entity set is
called the key attribute. For example, Roll_No will be unique for each
student. In ER diagram, the key attribute is represented by an oval with
underlying lines.

Key Attribute

2. Composite Attribute
An attribute composed of many other attributes is called a composite
attribute. For example, the Address attribute of the student Entity type
consists of Street, City, State, and Country. In ER diagram, the
composite attribute is represented by an oval comprising of ovals.

Composite Attribute

3. Multivalued Attribute

An attribute consisting of more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER
diagram, a multivalued attribute is represented by a double oval.

Multivalued Attribute
4. Derived Attribute

An attribute that can be derived from other attributes of the entity type is
known as a derived attribute. e.g.; Age (can be derived from DOB). In ER
diagram, the derived attribute is represented by a dashed oval.

Derived Attribute

The Complete Entity Type Student with its Attributes can be represented
as:
Entity and Attributes

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, the relationship type is
represented by a diamond and connecting the entities with lines.

Entity-Relationship Set

A set of relationships of the same type is known as a relationship set.


The following relationship set depicts S1 as enrolled in C2, S2 as
enrolled in C1, and S3 as registered in C3.
Relationship Set

Degree of a Relationship Set

The number of different entity sets participating in a relationship set is


called the degree of a relationship set.

1. Unary Relationship: When there is only ONE entity set participating in


a relation, the relationship is called a unary relationship. For example,
one person is married to only one person.

Unary Relationship

2. Binary Relationship: When there are TWO entities set participating in


a relationship, the relationship is called a binary relationship. For
example, a Student is enrolled in a Course.

Binary Relationship
3. Ternary Relationship: When there are three entity sets participating in
a relationship, the relationship is called a ternary relationship.

4. N-ary Relationship: When there are n entities set participating in a


relationship, the relationship is called an n-ary relationship.

What is 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:

1. One-to-One: When each entity in each entity set can take part only
once in the relationship, the cardinality is one-to-one. Let us assume
that a male can marry one female and a female can marry one male. So
the relationship will be one-to-one.

the total number of tables that can be used in this is 2.

one to one cardinality

Using Sets, it can be represented as:


Set Representation of One-to-One

2. One-to-Many: In one-to-many mapping as well where each entity can


be related to more than one entity and the total number of tables that
can be used in this is 2. Let us assume that one surgeon department can
accommodate many doctors. So the Cardinality will be 1 to M. It means
one department has many Doctors.

total number of tables that can used is 3.

one to many cardinality


Using sets, one-to-many cardinality can be represented as:

Set Representation of One-to-Many

3. Many-to-One: When entities in one entity set can take part only once
in the relationship set and entities in other entity sets can take part more
than once in the relationship set, cardinality is many to one. Let us
assume that a student can take only one course but one course can be
taken by many students. So the cardinality will be n to 1. It means that
for one course there can be n students but for one student, there will be
only one course.

The total number of tables that can be used in this is 3.

many to one cardinality

Using Sets, it can be represented as:


Set Representation of Many-to-One

In this case, each student is taking only 1 course but 1 course has been
taken by many students.

4. Many-to-Many: When entities in all entity sets can take part more than
once in the relationship cardinality is many to many. Let us assume that
a student can take more than one course and one course can be taken
by many students. So the relationship will be many to many.

the total number of tables that can be used in this is 3.


many to many cardinality

Using Sets, it can be represented as:

Many-to-Many Set Representation

In this example, student S1 is enrolled in C1 and C3 and Course C3 is


enrolled by S1, S3, and S4. So it is many-to-many relationships.

Participation Constraint
Participation Constraint is applied to the entity participating in the
relationship set.

1. Total Participation – Each entity in the entity set must participate in


the relationship. If each student must enroll in a course, the participation
of students will be total. Total participation is shown by a double line in
the ER diagram.

2. 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 students, the participation in the 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.

Total Participation and Partial Participation

Using Set, it can be represented as,


Set representation of Total Participation and Partial Participation

Every student in the Student Entity set participates in a relationship but


there exists a course C4 that is not taking part in the relationship.

How to Draw Entity Relationship Diagrams


(ERDs)
Last Updated : 03 Jun, 2024

Entity Relationship Diagrams serve as valuable tools for designing


complex systems and their relationships.
This article will go through the step-by-step process of designing an ER
diagram and defining how entities, attributes, and relationships are defined.
Entity relationship diagrams are important in database design and require a
clear structure for all data.

What is an Entity Relationship Diagram?

An Entity Relationship Diagram (ERD) is a graphical representation that


shows how entities, such as people, objects, or concepts, relate to each other
within a system.

ERDs are commonly used in database design to visualize the relationships


between entities and their attributes.

They help in understanding the logical structure of databases by showing


entities’ connections and relationships using symbols like rectangles,
diamonds, ovals, and connecting lines.

ERDs are essential for designing or debugging relational databases in


software engineering, business information systems, education, and research.

Need to Draw ER Diagram

ER diagram or ER model, is drawn to visually represent the relationships


between entities in a database system. Some benefits of drawing ER
diagrams for database design are:

1. It helps in understanding the data relationships.


2. ER diagrams are like a blueprint for designing a database.
3. Helps in communicating about databases with database designers,
developers, users, etc.
4. They help in describing different relationships and operations within
an organization.

How to Draw an Entity Relation Diagram (ERD)

A step-by-step process to draw an entity relation diagram (ERD) is:

Step 1: Identifying Entities

Determine the main objects you want to represent in the database. Eg,
“students”, “courses”, or “products”.

Step 2: Defining Attributes

Identify the properties(attributes) of properties of each entity. These attributes


provide more details about an entity.

Step 3: Specifing Relationships

Create relationships between entities to specify how entities interact with each
other. Relationships are verbs like “teaches”, “studies”, or “sells”.

Step 4: Drawing Entities

Draw entities as rectangle and write the name.

Step 5: Adding Attributes


To add attributes of a entitity write attributes inside the rectangle or connect
them with lines.

Step 6: Connecting Entities

Draw lines between the related entities to represent their connection.

Step 7: Specifying Cardinality

Indicate the minimum and maximum number of relationship instances


associated with an entity using notations like crow’s foot.

Step 8: Organizing ER Diagram

Organize all entities and relationships in a clean way for better readibility and
understanding.

Draw Entity Relationship Diagram Example

After learning the steps of how to draw an enitity relationship diagram, we will
create a demo ER diagram.

Let’s take an example of ER diagram for a bank through which we can learn
how to design an ER and understand all the required methods.

Entity Relationship Diagram for BANK


We will follow the steps mentioned above, to draw entity relationship diagram
for bank.

Defining Entities

A thing in the real world with an independent existence. It is may be an object


with physical existence (ex: house, person) or with a conceptual existence
(ex: course, job). The are represented by rectangle.

Entities for Bank are:

Bank, Branch, Employee, customer, loan, account.


Entities

Adding Attributes

Attributes are the kind of properties that describe the entities. They are
represented by ovals.

Attributes for Bank are:

● For Bank Entity the Attributes are Bname, code.


● For Branch Entity the Attributes are Blocation, Bname.
● For Employee Entity the Attributes are Eid, Designation, salary.
● For Customer Entity the Attributes are Cid, Cname, Address,
DOB.
● For Loan Entity the Attributes are Loan_no, amount, rate.
● For Account Entity the Attributes are acc_no, type.
Attributes

Establishing Relationships

Entities have some relationships with each other. Relationships define how
entities are associated with each other.

Let’s Establishing Relationships between them are:

● The Bank has branches.


● The Branch provides loan.
● The Employee works in branch.
● The Branch contains customers.
● The Customers has account.
● The Branch maintains account.
● The Customer avails loan.
Relationships

Specifying Cardinality

Cardinality defines the numerical constraints on the relationships between


entities. It is a notation that tells the ERD reader whether there are one,
many or some combination of those factors between each entity.

1. One to One relationship(1:1)

In the entity relationship diagram, the one to one relationship means that
single entity in one table is associated with single entity in another table.
For example, one driver have only one license.

2. One to Many relationship(1:N)


One to many relationships means that single entity in one table is related to
more than one entities in another table. For example, one bank has many
branches.

3. Many to One(N:1)

Many-to-one relationship in entity relationship diagram means that multiple


entities are related to only single entity in another table. For example, many
developers works on single project.

4. Many to Many relationship(M:N)

Many to many relationship means that multiple entities in one table is


associated with multiple entities in another table. For example, multiple
customers have multiple accounts.

Specify cardinality for Bank:

● Bank and branch has One to Many relationship (a bank has


multiple branches).
● Branch and loan has also One to Many relationship(a branch can
provide many loans).
● Branch and employee has One to Many relationship(one branch
has many employees).
● Branch and account has One to Many relationship(one branch has
many accounts).
● Branch and customer has Many to Many relationship(multiple
branches have multiple customers).
● Customer and account has Many to Many relationship(multiple
customers have multiple accounts).
● Customer and loan has Many to Many relationships(multiple
customers have multiple loans)

ER Diagram

Identify Primary Keys

Primary keys are the unique identifier for each record in database table. It is
denoted by an underline under the attribute name.

● The Primary key of Bank is code.


● The Primary key of Branch is branch_code.
● The Primary key of Employee is Eid.
● The Primary key of Customer is Cid.
● The Primary key of Loan is loan_no.
● The Primary key of Account is acc_no.
Final ER Diagram

The below diagram is our final entity relationship diagram for bank with all
entities, their attributes and the relationship between them with the
PRIMARY KEY and Cardinality ratio.

Final ER Diagram

Benefits of an ER Diagram

● ER diagrams provides a clear and visual representation of the


database structure. This make it easier for developers and designers
to understand the relationships between the entities.
● It is an effective communication tool for database designers and the
stakeholders which helps to understand the data model.
● ER diagrams serve as the foundation for designing the database
schema. They guide the creation of tables, relationships and
constraints in the database management system.
● Creating an ER diagram helps in understanding and analyzing the
data requirements of the system.
● Database managers can more quickly and efficiently undertake
maintenance activities, including adding new entities or changing
existing relationships, when they have a well-designed Entity
Relationship diagram that makes the database structure easy to
understand.

You might also like