ER Diagram - Entity Relationship Model in DBMS

In this tutorial, We will study about the ER diagram, components of the ER diagram - entity, attributes, relationships, keys, and cardinality. So let us start.

What is the ER diagram

ER diagram also known as the ER model is used for representing the data logically. It fulfills the requirement of the conceptual design of the database. It is used to represent relationships between different entity sets. The ER diagram looks more like a flowchart. But, ER Diagram contains many specialized symbols and the meanings of the symbols make this model unique. ER-diagrams have meanings that should be thoroughly understood so that we can create correct diagrams.

What is an entity

What is an attribute

What are the types of attributes

There are four types of attributes.

Simple attributes

Those attributes that can not be divided any further. Example: mobile phone number.

Composite attributes

Those attributes can be further divided. Example: name of a person, it can be divided into first name, middle name, and last name.

Derived attributes

Those attributes that are derived from other attributes. Example: experience can be derived from the date of joining.

Multivalued attributes

Those attributes can have multiple values. Example: a person can have multiple mobile numbers and email ids.

ER Diagram

In this figure student and course are the entities and studies is the relationship between the entities and attributes are name, roll no., class, course name and course no.

What is the relationship

What is cardinality

It is used to define the maximum number of relationships one entity can have with others. There are different types of cardinality like:

Many to many

One entity from A is associated with more than one entity from B and one entity from B is associated with more than one entity from A.
For example, Class as a group of students is associated with many faculty members, and many faculty members are associated with the class.

Many to many relationship

One to one

One entity from any entity set can be associated with another entity set B by at most on relation and vice versa.
For example, one employee can work only for one department and each department will have at most one employee.

One to one relationship

One to many

One entity from entity set A might be associated with multiple entities of the entity set B, but an entity from the entity set B can be associated with at most one entity.
For example, one department might consist of multiple employees.

one to many relationship

Many to one

One entity from the entity set B can be associated with multiple entities of the entity set A but every entity from the entity set A will be associated with one or more than one entity from the entity set B.
For example, many employees might belong to one department.

Many to one relationship

What is the degree of relationship?

The total number of various entity sets that are participating in a relationship set is called the degree of a relationship set.

Unary Relationship

When only one entity set is participating in relation. For example, a person can only marry a person.

Binary Relationship

When there are two entities that are participating in the relationship. For example, one student can go to only one school.

N-ary Relationship

When there is n number of entities set that are participating in a relation.

What is Participation Constraint?

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

Total Participation

Each and every entity in the entity set must participate in the relationship. Total participation is represented by a double line. For example, every student is opting for a course therefore there is total participation from students.

Partial Participation

Each and every entity in the relationship set need not participate in the relationship. Partial participation is shown by a single line. For example, every student might not be participating in every game.

What are the ER diagram notations?

ER- Diagram is the representation of data that describes how data is related to each other and defines the relationship between them.

ER diagram notations

Rectangles

This symbol is used to represent the entity.

Ellipses

This Symbol is used to represent attributes.

Diamonds

This symbol represents the relationship types.

Lines

It helps in linking the attributes to entity types and entity types with other relationship types.

Primary key

These attributes are underlined.

Double Ellipses

Used to represent multi-valued attributes.