E-R Diagram

E-R Diagram

An entity-relationship (ER) diagram is a specialized graphic that illustrates the relationships between entities in a database.ER-Diagram is a visual representation of data that describes how data is related to each other. ER diagrams often use symbols to represent three different types of information. Boxes are commonly used to represent entities. Diamonds are normally used to represent relationships and ovals are used to represent attributes.


Symbols and Notations



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.each entity is stored in a database table and every instance of an entity corresponds to a row in that table. In an ER diagram, each entity is depicted as a rectangular box with the name of the entity contained within it. Consider an example of an Organisation. Employee, Manager, Department, Product and many more can be taken as entities from an Organisation.


Weak Entity

A weak entity is an entity that must defined by a foreign key relationship with another entity as it cannot be uniquely identified by its own attributes alone.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.


2) Attribute

An Attribute describes a property or characterstic of an entity. For example, Name, Age, Address etc can be attributes of a Student. Databases contain information about each entity. This information is tracked in individual fields known as attributes, which normally correspond to the columns of a database table.An attribute is represented using eclipse.


Key Attribute

A key attribute is the unique, distinguishing characteristic of the entity. For example, an employee’s social security number might be the employee’s 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.


Composite Attribute

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


3) Relationship

Relationships illustrate how two entities share information in the database structure.A Relationship describes relations between entities. Relationship is represented using diamonds.


There are three types of relationship that exist between Entities.

  • Binary Relationship
  • Recursive Relationship
  • Ternary Relationship

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 ony 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

In some cases, entities can be self-linked. For example, employees can supervise other employees.


Ternary Relationship

Relationship of degree three is called Ternary relationship.

Admin has written 171 articles

Leave a Reply