er diagram eaxmples
DBMS ER diagram Tutorial gate study material for cse

ER Diagram Examples Tutorial

Entity Relationship Diagram Explanation with Examples 

This ER diagram examples based tutorial will learn about some important concepts of entity-relationship diagrams such as ER diagram definition, ER diagram symbols and notations, ER diagram examples, and different components of an ER diagram.

The entity Relation Diagram is an important model that helps design relation or table in a relational database management system(RDBMS).

A computer science student should know the er diagram concepts and know how to make an ER Diagram for an application.

Frequently Asked Questions

By the end of this ER Diagram examples based tutorial, computer science graduate will get the answer to the following questions

  • What is the E-R Diagram in DBMS?
  • Why is the ER diagram used?
  • Is a relationship in the ER diagram?
  • What is the use of ER Diagram?
  • What is an entity?
  • What are different ER diagram symbols?
  • Different ER diagram examples.
  • What are the different components of an ER diagram?
  • What do you understand by simple attributes?
  • What is a derived attribute?
  • What are multi-value and single-value attributes?
  • What are the different relationships among the entities in an ER diagram?
  • What is the primary key?
  • What is a composite key?
  • What do you mean by total participation and partial participation in the ER diagram?
  • What are different ER diagram keys?

What is the Entity-Relationship Model?

  • Entity Relationship Diagram is a model in DBMS which is used to represent the relation between real-world entities.
  • Entity Relationship Diagram shows the conceptual view of a database at any instance of time.
  • ER Model shows how different entities are related to each other in any system.
  • Peter Chen introduced the ER Model in the Paper entitled “The Entity Relationship Diagram” – Towards a Unified View of Data, he explained this model.
  • ER diagrams are the diagrammatic representation of the Database Designs.

So, they are mainly used to design Relational Databases. Also, they are used during the planning stage of any Software Engineering Project.

er diagram examples

Components of Entity Relationship Diagram Examples

Some major components of an Entity Relationship Diagram are as follows –

  • Entity
  • Attributes
  • Relationship

Explanation of Each above Component is given below –

Entity

Any real-world objects came under the category of entity. An entity can be any person, any object, any place, or event relevant to a given database system.

Examples: A Pharmacy Management system can have entities such as drugs, cash, injections, bills etc.

There is a kind of entity that depends on the existence of other entity & that is known as the Weak Entity. Entities are represented using Rectangles.

Attribute

 They are the properties through which an entity is defined. Suppose there is an entity called Student, then Student’s name, Student’s age, Student’s email address, Student’s phone number came under the category of the attribute of the entity” “Student”

There is the following kind of attributes:

  • Simple attribute: Attribute whose values are already atomic & cannot be divided further. For example, The first name & last name of an entity “Student”.
  • Composite attribute: Attributes that are made up of more than one simple attributes. For example, The attribute ‘Name’ contains First Name, Middle name and last name etc.
  • Single valued attribute: These attributes contain only single values. For example, The attribute “Age” of an entity “Student.”
  • Multi-valued attribute: These attributes contain multiple values. A double oval represents t. For example’ ‘Phone Number” of an entity” “Student.”
  • Derived attribute: The attributes derived from other attributes & are not present in the database system are known to be called Derived Attributes. For example, The ‘Age’ of the entity ‘Student’ can be derived from the attribute “Date of Birth”. So age is the derived attribute. A dotted oval represents a derived attribute.

Relationship

Relationship represents the association among the entities of an ER diagram. The diamond symbol represents it.

ER Diagram Notations and Symbols

Different notations and symbols used in Entity Relationship Diagram are shown in the following figure

er diagram examples

Relationships between Entities

  • If there are more than one entities in a DBMS, then there is a more chance that all the entities are related to each other through some relationships.
  • These relationships are represented using a Diamond Shaped Box, and as usual, entities are represented using Rectangular Box. All the entities in a relationship are connected using a hard line.
  • When two entities are connected, then it is known as Binary Relationship. The number of instances of any entity associated with any other relation is known as Cardinality of the Entity.
  • Relationships are the association between the entities.

Types of Relationship in Entity Relationship Diagram

Type of Relationship in Entity Relationship Diagram are of four types

  • One to One
  • One to Many
  • Many to One
  • Many to Many

 

Explanation of each type of Relationship is given below with suitable example.

  1.  ONE TO ONE

In one to one mapping cardinality, an entity in an entity set A can be associated with at most one entity in another entity set B. An entity in set B can be associated with at most one entity in set A.

er diagram

Example: One Student can enroll in at-most one course, or one course can be enrolled by at most one Student.           

  1.  ONE TO MANY

When an instance or entity in an entity set A is associated with any number (zero or many) of entities in other entity set B or an entity in entity set B is associated with at most one entity in the entity set A, then this type of relationship is known as one to many relationships. 

Example: One Student can enroll in any number of course ( including zero), or one course can be enrolled by at most one Student.

  1.  MANY TO ONE

When an entity or instance of an entity set A is associated with at most one entity in other entity set B or an entity in entity set B can be associated with any number of entities of an entity set A, then it is known as one to many relationships. 

 

er diagram examples

Example : One student can enrolled in at most one course or one course can be enrolled by any( zero or many) students.

  1. MANY TO MANY

When an entity in an entity set A is associated with any number of entities in an entity set B and vice versa then this type of cardinality or mapping is known as many to many. Mainly ‘Many’ or ‘N’ should be in the both side of the relationship.

 er diagram examples

Example: One student can enroll in any number of course ( zero or many ) or one course can be enrolled by any( zero or many ) number of students.

ER Diagram Examples with Solution

An ER diagram for Customer and Loan entity is as shown in following figure.

Relationship between customer and loan entity set is borrower. It means customer borrow the loan. Different attributes of customer and loan entity are also shown.

Customer_id is the key attribute of Customer entity similarly loan_id is the key attribute of loan entity. 

er diagram examples

Keys in Entity Relationship Diagram

  • In ER Modeling, Keys are used for indexing. Through keys, one can easily access any row without wasting much time and efficiency.
  • It is very usable in tables which millions of data or rows. Let’s take an example of a table” “EMPLOYE” with the fields” “EMP_ID, EMP_F_NAME, EMP_L_NAME, EMP_PHNO, EMP_EMAI”.

Basically, there is 4 type of keys which plays a major role in ER Modeling, which are as follows:

  1. Primary key: It is that column of a table that has all the unique values inside it. Through the primary key, the data in the table will be identified uniquely.

Example. In a table” “EMPLOYE”, the” “EMP_I” (Employee ID), which is assigned to every Employee uniquely, is known to be the primary key of the table.

  1.  Composite key

When two or more attributes are combined to form a primary key column or identify any table data uniquely, this is a composite key.

Example. In a table” “EMPLOYE”, the” “EMP_PHN” &” “EMP_EMAI” attributes, if combined, form a type of primary key which is assigned to every Employee uniquely, is known to be the composite key of the table.

Participation Constraints in ER Diagram

There are two types of participation constraints, and these are as follows.

  • Total Participation
  • Partial Participation

Let’s understand each type of participation

Total Participation in ER Diagram

  • In total participation, each entity is involved in the relationship. Double lines in the ER diagram represent total participation.
  • Total participation specifies that each entity in the entity set must compulsorily participate in at least one relationship instance, the relationship set.
  • Total participation sometimes is also known as mandatory participants.

Total Participation Example – In the following figure Double line between the entity set” “Student” and relationship set” “Enrolled i” signifies total participation.

 
 
er diagram examples

Partial Participation in ER Diagram

  • In this types of participation not all entities are involved in the relationship. Partial participation is represented by single line.
  • It specifies that each entity in the entity set may or may not participate in the relationship instance in that relationship set.
  • That is why, it is sometime also known as optional participation

    Partial Participation Examples



er diagram examples
Here in this example Single line between the entity set “Course” and relationship set “Enrolled in” represents partial participation.
It specifies that there might exist some courses for which no enrollments are made.

Conclusion and Summary

We have discussed the following useful concepts of er diagram in this tutorial.

  • Introduction to er diagram and it’s use in database design.
  • Definition of the term entity and attribute, types of the attributes of an entity.
  • Mapping cardinality and its types.
  • Concept of Participation in er diagram.
  • Different types of keys

Please provide your feedback or leave comment so that we can improve quality of our tutorial and provides you a good quality tutorials. I request to students to ask the query.

If you find this er diagram examples tutorial useful then please Like and Share the post on Facebook, Twitter, Linkedin through their icons as given below.

Previous Tutorial – Database Languages

Next Tutorial – Difference Between Generalization and Specialization

Leave a Reply

Your email address will not be published. Required fields are marked *