E-R Diagram

ER-Diagram is a visual representation of data that describes how data is related to each other.

example of er-diagram

Symbols and Notations

ER diagrams symbols
ER diagrams symbols

Components of E-R Diagram

The E-R diagram has three main components.

1) Entity

An Entity can be any object, place, person or class. In E-R Diagram, an entity is represented using rectangles. Consider an example of an Organisation. Employee, Manager, Department, Product and many more can be taken as entities from an Organisation.

Entity example

Weak Entity

Weak entity is an entity that depends on another entity. Weak entity doen't have key attribute of their own. Double rectangle represents weak entity.

weak Entity example

2) Attribute

An Attribute describes a property or characterstic of an entity. For example, Name, Age, Address etc can be attributes of a Student. An attribute is represented using eclipse.

attribute example

Key Attribute

Key attribute represents the main characterstic of an Entity. It is used to represent Primary key. Ellipse with underlying lines represent Key Attribute.

key attribute example

Composite Attribute

An attribute can also have their own attributes. These attributes are known as Composite attribute.

composite attribute example

3) Relationship

A Relationship describes relations between entities. Relationship is represented using diamonds.

relationship example

There are three types of relationship that exist between Entities.

Binary Relationship

Binary Relationship means relation between two Entities. This is further divided into three types.

  1. One to One : This type of relationship is rarely seen in real world.
  2. one-to-one example

    The above example describes that one student can enroll only for one course and a course will also have only one Student. This is not what you will usually see in relationship.

  3. One to Many : It reflects business rule that one entity is associated with many number of same entity. For example, Student enrolls for only one Course but a Course can have many Students.
  4. one-to-many example

    The arrows in the diagram describes that one student can enroll for only one course.

  5. Many to Many :
  6. many-to-many example

    The above diagram represents that many students can enroll for more than one courses.

Recursive Relationship

When an Entity is related with itself it is known as Recursive Relationship.

recursive relationship example

Ternary Relationship

Relationship of degree three is called Ternary relationship.