A Beginners guide to entity relationship modelling and diagrams


A Beginner’s Guide to Entity-Relationship Modelling (ERM) and Diagrams (ERDs)

Introduction

Entity Relationship Modelling can be a tricky concept to get your head around. Imagine you’re designing a library system, an online store, or even a social media platform. You’ll need a way to organize and connect all the data – books, users, transactions, and more. Without a clear structure, things can quickly become a chaotic mess! This is where Entity-Relationship Modelling (ERM) and Entity-Relationship Diagrams (ERDs) step in to save the day.

Think of ERM as the blueprint for your database. Just like architects draw detailed plans before constructing a building, database designers use ERM to visualise how the pieces of data in their system fit together. An ERD is the diagram representing this plan, making it easier to understand, design, and build.

By the end of this guide, you’ll not only understand the basics of ERM and ERDs, but you’ll also be ready to create your own diagrams for any scenario. Let’s dive in!


What is Entity-Relationship Modelling (ERM)?

At its core, ERM is a way to map out the information (data) that a system needs to store and how different pieces of that data are connected. This model is particularly important for database design because it ensures that the structure of the database is logical, organized, and free of unnecessary repetition.

In simple terms, ERM answers these questions:

  • What data do we need to store? (Entities)
  • What details about this data are important? (Attributes)
  • How are different pieces of data connected? (Relationships)

Breaking Down ERM: Key Concepts

To understand ERM, we need to know its building blocks. Let’s explore these concepts with plain explanations and examples.

1. Entities

An entity is any object, person, or thing in the system that you want to store data about. Each entity will eventually become a table in your database.

Think of entities as nouns. For example:

  • In a library system, entities might include Book, Member, and Loan.
  • In a school system, entities could be Student, Teacher, and Class.

Types of Entities

  • Strong Entities: These exist independently. For example, a Book exists whether or not it’s borrowed.
  • Weak Entities: These depend on another entity to exist. For example, a Loan depends on both a Member and a Book.

2. Attributes

Attributes describe the properties or characteristics of an entity. If an entity is a person, their attributes might include Name, Age, and Address.

Think of attributes as adjectives describing the entity. For example:

  • A Book might have the attributes Title, Author, and ISBN.
  • A Member might have Name, Email, and MembershipID.

Each attribute will later become a column in the database table for that entity.

Special Attributes

  • Primary Key: A unique identifier for each record in an entity. For example, MembershipID uniquely identifies each library member.
  • Foreign Key: An attribute in one entity that links to the primary key of another entity. This is how relationships are established between entities.

3. Relationships

Relationships define how two entities are connected. For example:

  • A Member borrows a Book.
  • A Student enrolls in a Class.

Types of Relationships

  • One-to-One (1:1): One entity is linked to only one other entity. For example, each Person might have one Passport.
  • One-to-Many (1:N): One entity is linked to many others. For example, a Teacher can teach multiple Classes.
  • Many-to-Many (M:N): Many entities are linked to many others. For example, Students can enroll in multiple Classes, and each Class can have multiple Students.

What is an Entity-Relationship Diagram (ERD)?

An ERD is a visual representation of your Entity-Relationship Model. It shows entities, their attributes, and relationships in a simple, intuitive way, making it easy for anyone to understand how the data is structured.

Common Symbols in ERDs

  • Rectangles: Represent entities.
  • Ovals: Represent attributes.
  • Diamonds: Represent relationships.
  • Lines: Connect entities to their relationships and attributes.

Here’s how it works:

  1. Draw rectangles for each entity.
  2. Connect entities with diamonds to show relationships.
  3. Add ovals around entities to list their attributes.

Step-by-Step Guide: Creating an ERD

Let’s create an ERD for a Library System:

  1. Identify the Entities: What are the key objects in the system?
    • Entities: Book, Member, Loan.
  2. Identify the Attributes: What details do we need about each entity?
    • Book: BookID, Title, Author, ISBN.
    • Member: MemberID, Name, Email.
    • Loan: LoanID, LoanDate, ReturnDate.
  3. Define the Relationships: How are these entities connected?
    • A Member borrows multiple Books via Loans.
  4. Draw the ERD: Represent the entities, attributes, and relationships visually.
    Check out the diagram below!
library er diagram

Examples of ERDs

To give you a better idea of how ERDs work, here are a few examples with brief explanations:

1. Hospital Management System

  • Entities: Patient, Doctor, Appointment.
  • Relationships:
    • A Patient has multiple Appointments.
    • A Doctor is scheduled for multiple Appointments.
hospital management

2. E-commerce System

  • Entities: Customer, Product, Order, OrderItem.
  • Relationships:
    • A Customer places multiple Orders.
    • An Order contains multiple OrderItems.
ecommerce system

Your Turn!

Now that you understand the basics, try creating an ERD for a system you’re familiar with. Here’s a tip: start small, identify the entities, their attributes, and relationships, then build from there.


Conclusion

Entity-relationship modeling and ERDs are invaluable tools for designing databases. They help you think clearly about your data, avoid mistakes, and build systems that are efficient and easy to manage. Whether you’re working on a school project or a professional application, mastering ERDs will set you up for success.


If you’re ready to start creating your own ERDs, give it a try and let your creativity flow. And if you need more help, feel free to reach out or drop a comment below!


1 thought on “A Beginners guide to entity relationship modelling and diagrams”

  1. Entity Relationship Diagram is awful to make manually, but it really helps you to visual you database so that other may also understand how the database works for the program

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top