Entity-Relationship Diagram

Entity-Relationship Diagram

Published by: Sareena Kumari Basnet

Published date: 23 Jul 2024

Entity-Relationship Diagram

ER Model- Basic Concepts

The ER model defines the conceptual view of a database. It works around real-world entities and the associations among them. At view level, the ER model is considered a good option for designing databases.
Entity Relationship Diagram, also known as ERD, ER Diagram or ER model, is a type of structural diagram for use in database design. An ERD contains different symbols and connectors that visualize two important information: The major entities within the system scope, and the inter-relationships among these entities.

Sample E-R Diagram

Components of a ER Diagram

  • Rectangle: Represents Entity sets.
  • Ellipses: Attributes
  • Diamonds: Relationship Set
  • Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
  • Double Ellipses: Multivalued Attributes
  • Dashed Ellipses: Derived Attributes
  • Double Rectangles: Weak Entity Sets
  • Double Lines: Total participation of an entity in a relationship set

1. Entity

An entity is an object or component of data. An entity is represented as rectangle in an ER diagram.
For example: In the following ER diagram we have two entities Student and College and these two entities have many to one relationship as many student's study in a single college. 



Weak Entity:

  • An entity that cannot be uniquely identified by its own attributes and relies on the relationship with other entity is called weak entity. The weak entity is represented by a double rectangle.
  • For example - a bank account cannot be uniquely identified without knowing the bank to which the account belongs, so bank account is a weak entity.

2. Attribute

An attribute describes the property of an entity. An attribute is represented as Oval in an ER diagram. There are four types of attributes:

  • Key attribute
  • Composite attribute
  • Multivalued attribute
  • Derived attribute

a) Key attribute

  • A key attribute can uniquely identify an entity from an entity set. For example, student roll number can uniquely identify a student from a set of students.
  • Key attribute is represented by oval same as other attributes however the text of key attribute is underlined.

b) Composite attribute

  • An attribute that is a combination of other attributes is known as composite attribute. For example,
  • In the below example: Address is a composite attribute represented by an elliptical shape, and it can be further subdivided into many simple attributes like Street, City, State, Country, Landmark, etc.

c) Multivalued attribute

  • An attribute that can hold multiple values is known as multivalued attribute. It is represented with double ovals in an ER Diagram.
  • For example - A person can have more than one phone numbers so the phone number attribute is multivalued.

d) Derived attribute

  • A derived attribute is one whose value is dynamic and derived from another attribute. It is represented by dashed oval in an ER Diagram.
  • For example - Person age is a derived attribute as it changes over time and can be derived from another attribute (Date of birth).

3. Relationship (Mapping Cardinalities)

A relationship is represented by diamond shape in ER diagram, it shows the relationship among entities. There are four types of relationships:

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

a) One to One

  • When a single instance of an entity is associated with a single instance of another entity then it is called one to one relationship. For example, a person has only one passport and a passport is given to one person.

b) One to Many

  • When a single instance of an entity is associated with more than one instances of another entity then it is called one to many relationships. For example - a customer can place many orders but an order cannot be placed by many customers.

c) Many to One

  • When more than one instances of an entity is associated with a single instance of another entity then it is called many to one relationship. For example - many students can study in a single college but a student cannot study in many colleges at the same time.

d) Many to Many

  • When more than one instances of an entity are associated with more than one instances of another entity then it is called many to many relationships.
  • For example, a can be assigned to many projects and a project can be assigned to many students.

 

FAQs About Topic
An ERD is a graphical representation of entities and their relationships, and it is commonly used in database design to depict a system's data structure.
The main components include: Entities, Attributes and Relationships.
A weak entity is represented as a double rectangle and depends on a strong entity for survival, which usually has a partial key (double oval).