top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Understanding Entity Relationship Diagrams

ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that displays the relationship of entities stored in a database. In other words, ER diagrams help to explain the logical structure of databases. ER diagrams are created based on three basic concepts: entities, attributes and relationships.


What is the use of ER Diagrams?

Though they can be used to model almost any system they are primarily used in the following areas.


ER Models in Database Design

They are widely used to design relational databases. The entities in the ER schema become tables, attributes and converted the database schema. Since they can be used to visualize database tables and their relationships it’s commonly used for database troubleshooting as well.


Entity relationship diagrams in software engineering

Entity relationship diagrams are used in software engineering during the planning stages of the software project. They help to identify different system elements and their relationships with each other. It is often used as the basis for data flow diagrams as they are commonly known.


For example, an inventory software used in a retail shop will have a database that monitors elements such as purchases, item, item type, item source and item price. Rendering this information through an ER diagram would be something like this:



In the diagram, the information inside the oval shapes are attributes of a entity item.


Entity Relationship Diagram (ERD) Symbols and Notations

There are three basic elements in an ER Diagram: entity, attribute, relationship. There are more elements which are based on the main elements. They are weak entity, multi valued attribute, derived attribute, weak relationship, and recursive relationship. Cardinality and ordinality are two other notations used in ER diagrams to further define relationships.


Entity

An entity can be a person, place, event, or object that is relevant to a given system. For example, a school system may include students, teachers, major courses, subjects, fees, and other items. Entities are represented in ER diagrams by a rectangle and named using singular nouns.



Attribute

An attribute is a property or characteristic of an entity, relationship, or another attribute. In the below example, Name is an attribute of the entity Student. An entity can have as many attributes as necessary. Meanwhile, attributes can also have their own specific attributes. For example, the attribute “student address” can have the attributes number, street, city, and state. These are called composite attributes. Attributes are represented by oval shapes.



Relationship

Relationships are represented by diamond-shaped box. Name of the relationship is written inside the diamond-box. All the entities (rectangles) participating in a relationship, are connected to it by a line.

  • One-to-one − When only one instance of an entity is associated with the relationship, it is marked as ‘1:1’. The following image reflects that only one instance of each entity should be associated with the relationship. It depicts one-to-one relationship.


  • One-to-many − When more than one instance of an entity is associated with a relationship, it is marked as ‘1:N’. The following image reflects that only one instance of entity on the left and more than one instance of an entity on the right can be associated with the relationship. It depicts one-to-many relationship.


  • Many-to-one − When more than one instance of entity is associated with the relationship, it is marked as ‘N:1’. The following image reflects that more than one instance of an entity on the left and only one instance of an entity on the right can be associated with the relationship. It depicts many-to-one relationship.


  • Many-to-many − The following image reflects that more than one instance of an entity on the left and more than one instance of an entity on the right can be associated with the relationship. It depicts many-to-many relationship.


Recursive Relationship

If the same entity participates more than once in a relationship it is known as a recursive relationship. In the below example an employee can be a supervisor and be supervised, so there is a recursive relationship.


There are many other concepts involved in the creation of ER diagram, but in this blog we will stick with the basic ones.


How to Draw ER Diagrams

Below points show how to go about creating an ER diagram.

  1. Identify all the entities in the system. An entity should appear only once in a particular diagram. Create rectangles for all entities and name them properly.

  2. Identify relationships between entities. Connect them using a line and add a text or a diamond in the middle describing the relationship.

  3. Add attributes for entities. Give meaningful attribute names so they can be understood easily.

In a complex system, it can be a nightmare to identify relationships. With more practice we can build more complex and meaningful diagrams.


ER Diagram Best Practices

  1. Provide a clear and appropriate name for each entity, attribute, and relationship in the diagram. Terms that are simple and familiar are always preferred. Meanwhile attribute names must be meaningful, unique, and easily understandable.

  2. Remove redundant or unnecessary relationships between entities.

  3. Never connect a relationship to another relationship.

  4. Make effective use of colors. You can use colors to classify similar entities or to highlight key areas in your diagrams.

Benefits of ER diagrams

ER diagrams constitute a very useful framework for creating and manipulating databases. First, ER diagrams are easy to understand and do not require a person to undergo extensive training to be able to work with it efficiently and accurately. This means anyone can learn how to do ER diagrams and use them to effectively communicate to the developers, customers or end users regardless of their IT background.


Second, ER diagrams are readily convertible into relational tables which can be used to quickly build databases. In addition, ER diagrams can directly be used by database developers as the blueprint for implementing data in specific software applications.


1,406 views0 comments

Recent Posts

See All
bottom of page