VOOZH about

URL: https://www.geeksforgeeks.org/sql/how-to-draw-entity-relationship-diagrams/

⇱ Steps to Draw an Entity Relationship Diagram - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Steps to Draw an Entity Relationship Diagram

Last Updated : 18 Apr, 2026

An Entity Relationship Diagram (ERD) is a graphical representation that shows how entities, such as people, objects or concepts, relate to each other within a system. ERDs are commonly used in database design to visualize the relationships between entities and their attributes.

  • Represent the logical structure of databases.
  • Use symbols (rectangles, diamonds, ovals, lines) to show entities and relationships.
  • Used in designing and debugging relational databases.

Need to Draw ER Diagram

ER diagram or ER model, is drawn to visually represent the relationships between entities in a database system. Some benefits of drawing ER diagrams for database design are:

  1. It helps in understanding the data relationships.
  2. ER diagrams are like a blueprint for designing a database.
  3. Helps in communicating about databases with database designers, developers, users, etc.
  4. They help in describing different relationships and operations within an organization.

Steps to Create an Entity Relationship Diagram (ERD)

A step-by-step process to draw an entity relation diagram (ERD) is:

Step 1. Identifying Entities: Determine the main objects you want to represent in the database. E.g., "students", "courses" or "products".

Step 2. Drawing Entities: Draw entities as rectangles and label them with their names.

Step 3. Defining Attributes: Identify the properties (attributes) of each entity. These attributes provide more details about an entity.

Step 4. Adding Attributes: Add attributes to the entities by either writing them inside the rectangle or connecting them using ovals and lines.

Step 5. Specifying Relationships: Create relationships between entities to show how they interact with each other. Relationships are usually verbs like teaches, studies or sells.

Step 6. Connecting Entities: Draw lines between the related entities to represent their connection.

Step 7. Specifying Cardinality: Indicate the minimum and maximum number of relationship instances associated with an entity using notations like crow's foot.

Step 8. Organizing ER Diagram: Organize all entities and relationships in a clean way for better readability and understanding.

Sample ER Diagram

After learning how to draw an ER diagram, let’s create a demo using a bank example to understand its design and methods.

Entity Relationship Diagram for BANK

We will follow the steps mentioned above, to draw entity relationship diagram for bank.

A real-world object with independent existence, either physical (house, person) or conceptual (course, job), is called an entity and is represented by a rectangle

Entities for Bank: Bank, Branch, Employee, customer, loan, account.

πŸ‘ er_diagram_4

Adding Attributes

Attributes are the kind of properties that describe the entities. They are represented by ovals.

Attributes for Bank are:

  • For Bank Entity the Attributes are Bname, code.
  • For Branch Entity the Attributes are Blocation, Bname.
  • For Employee Entity the Attributes are Eid, Designation, salary.
  • For Customer Entity the Attributes are Cid, Cname, Address, DOB.
  • For Loan Entity the Attributes are Loan_no, amount, rate.
  • For Account Entity the Attributes are acc_no, type.
πŸ‘ er_diagram_3

Establishing Relationships

Entities have some relationships with each other. Relationships define how entities are associated with each other.

Let's Establishing Relationships between them are:

  • The Bank has branches.
  • The Branch provides loan.
  • The Employee works in branch.
  • The Branch contains customers.
  • The Customers has account.
  • The Branch maintains account.
  • The Customer avails loan.
πŸ‘ er_diagram_2

Specifying Cardinality

Cardinality defines the numerical constraints on the relationships between entities. It is a notation that tells the ERD reader whether there are one, many or some combination of those factors between each entity.

1. One to One relationship(1:1)

A One-to-One (1:1) relationship in an ERD means one entity in a table is linked to exactly one entity in another table. Examples:

  • One Driver β†’ One License
  • One Person β†’ One Passport

2. One to Many relationship(1:N)

A One-to-Many relationship means one entity in a table can be associated with multiple entities in another table. Examples:

  • One Bank β†’ Many Branches
  • One Branch β†’ Many Employees

3. Many to One(N:1)

A Many-to-One relationship means multiple entities in one table are linked to a single entity in another table. Examples:

  • Many Employees β†’ One Branch
  • Many Accounts β†’ One Customer
  • Many Loans β†’ One Branch

4. Many to Many relationship(M:N)

A Many-to-Many relationship means multiple entities in one table are associated with multiple entities in another table. Examples:

  • Many Students ↔ Many Courses
  • Many Customers ↔ Many Products
  • Many Doctors ↔ Many Patients

Specify cardinality for Bank:

  • Bank β†’ Branch : One-to-Many (One bank has many branches)
  • Branch β†’ Loan : One-to-Many (One branch provides many loans)
  • Branch β†’ Employee : One-to-Many (One branch employs many employees)
  • Branch β†’ Account : One-to-Many (One branch maintains many accounts)
  • Branch β†’ Customer : One-to-Many (One branch has many customers)
  • Customer β†’ Account : One-to-Many (One customer has many accounts)
  • Customer β†’ Loan : One-to-Many (One customer can take many loans)
πŸ‘ er_diagram_5

Identify Primary Keys

Primary keys are the unique identifier for each record in database table. It is denoted by an underline under the attribute name.

  • The Primary key of Bank is code.
  • The Primary key of Branch is Bcode.
  • The Primary key of Employee is Eid.
  • The Primary key of Customer is Cid.
  • The Primary key of Loan is loan_no.
  • The Primary key of Account is acc_no.

Final ER Diagram

The below diagram is our final entity relationship diagram for bank with all entities, their attributes and the relationship between them with the PRIMARY KEY and Cardinality ratio.

πŸ‘ er_diagram_1
Comment