An Entity Relationship Diagram (ERD) is a graphical representation of a database that shows entities, attributes, and relationships between them.
- Serves as a blueprint for database design.
- Improves communication between designers, developers, and users.
Steps to Create an ERD
A step-by-step process to draw an entity relation diagram (ERD) is:
- Identifying Entities: Determine the main objects you want to represent in the database. E.g., "students", "courses" or "products".
- Drawing Entities: Draw entities as rectangles and label them with their names.
- Defining Attributes: Identify the properties (attributes) of each entity. These attributes provide more details about an entity.
- Adding Attributes: Add attributes to the entities by either writing them inside the rectangle or connecting them using ovals and lines.
- Specifying Relationships: Create relationships between entities to show how they interact with each other. Relationships are usually verbs like teaches, studies or sells.
- Connecting Entities: Draw lines between the related entities to represent their connection.
- Specifying Cardinality: Indicate the minimum and maximum number of relationship instances associated with an entity using notations like crow's foot.
- 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
An entity is a real-world object, either physical or conceptual, represented by a rectangle in an ER diagram.
Entities for Bank: Bank, Branch, Employee, customer, loan, account.

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.

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.

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)

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.
