Skip to content
BENIBIX Learn

Entity-Relationship Diagram (ERD)

Data🧭 FoundationsData Modeling

Also known as ERD, ER Diagram, Entity-Relationship Model, Database Diagram

A drawing of boxes and lines. It shows the things you track and how they link.

Think of it like

It is like a family tree. Boxes are people, and lines show who belongs to whom.

Example

Before building a booking app, Emma draws an ERD. It shows that one member can make many bookings, but each booking is for one class.

Why it matters

A drawing shows mistakes that are hard to spot in tables. Fixing a line on paper is far cheaper than fixing a live database.

Definition

An entity-relationship diagram is a drawing of a data model. Each box is an entity, a thing you track, like a customer or an order. Inside the box are the fields you keep about it. Lines between boxes show how the things link. Marks at the ends of a line show how many, such as one customer to many orders.

Example code

mermaid
erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
An ERD typed as text. A tool draws it as boxes, with one customer to many orders.
One customer places many orders. Each order holds many line items.

Common mistake

Drawing every field and table at once. Start with the main boxes and lines, then add the detail.

Key takeaways

  1. 1
    Boxes are things. Each box is one thing you track.
  2. 2
    Lines are links. A line shows two things are related.
  3. 3
    Ends are counts. Marks on the ends say one or many.

Compare

Learn it properly