What an ER diagram shows

An ER diagram has three components:

  • Entities — the tables in your database (User, Order, Product)
  • Attributes — the columns in each table (id, email, created_at), with primary keys (PK) and foreign keys (FK) marked
  • Relationships — how entities connect, including cardinality (one-to-many, many-to-many, one-to-one)

ER diagrams are the standard way to communicate database structure between developers, designers, and clients before any code is written. They also document an existing database for onboarding and auditing.

Cardinality notation

The most confusing part of ER diagrams for beginners is the notation on relationship lines. The most common standard today is crow's foot notation:

SymbolMeaningExample
||Exactly oneAn order has exactly one customer
|oZero or one (optional one)A user may have zero or one profile photo
{ or o{Zero or manyA customer may have zero or many orders
||--o{One-to-manyOne customer → many orders
}|--|{Many-to-manyStudents ↔ Courses (via enrollment table)
||--||One-to-oneUser ↔ Profile (each has exactly one)

How to draw one online free

Option 1: TheFreeAITools ER Diagram Maker (no signup)

The free ER diagram maker uses Mermaid erDiagram syntax and renders the diagram instantly as you type. Drag nodes to rearrange the layout, then export to SVG or PNG. No account, no watermark.

The syntax is simple. A minimal ER diagram looks like this:

erDiagram
  users {
  uuid id PK
  string email
  timestamp created_at
  }
  orders {
  uuid id PK
  uuid user_id FK
  decimal total
  string status
  }
  users ||--o{ orders : places

Paste this into the tool and it renders a diagram with the relationship arrow automatically. Add more entities and relationships the same way.

Option 2: Draw.io (no signup)

Draw.io (diagrams.net) has dedicated ER diagram shapes. Use the Entity Relationship shape library, draw entities as rectangles with attribute rows, and connect them with crow's foot notation connectors. Works offline after load, saves to local files or Google Drive. No account required for local use.

Option 3: Mermaid Live Editor (no signup)

The official Mermaid Live Editor at mermaid.live is the fastest way to iterate on a text-based ER diagram. The same erDiagram syntax works here. The output can be exported as SVG or PNG and the diagram link is shareable without an account. This is the best option if your team already uses Mermaid in documentation.

Worked example: an e-commerce database

Here is a complete ER diagram for a simple e-commerce system:

erDiagram
  users {
  uuid id PK
  string email
  string name
  timestamp created_at
  }
  addresses {
  uuid id PK
  uuid user_id FK
  string street
  string city
  string country
  }
  products {
  uuid id PK
  string name
  string sku
  decimal price
  int stock
  }
  orders {
  uuid id PK
  uuid user_id FK
  uuid shipping_address_id FK
  string status
  decimal total
  timestamp created_at
  }
  order_items {
  uuid id PK
  uuid order_id FK
  uuid product_id FK
  int quantity
  decimal unit_price
  }

  users ||--o{ addresses : "has"
  users ||--o{ orders : "places"
  orders ||--o{ order_items : "contains"
  products ||--o{ order_items : "in"
  addresses ||--o{ orders : "ships to"

Common mistakes

  • Missing FK attributes — always list the foreign key column (e.g.,user_id FK) explicitly. It makes the relationship visible in both the entity box and the connector.
  • Wrong cardinality direction — users ||--o{ ordersmeans "one user, zero or many orders." Read left-to-right: the symbol closest to each entity describes how many of that entity participate.
  • Modeling many-to-many without a junction table — in SQL there is no native many-to-many. A Students ↔ Courses relationship requires an enrollments junction table with student_id FK and course_id FK. Show the junction table in the ER diagram, not a direct many-to-many connector.

ER diagram vs class diagram

An ER diagram models the database. A class diagram models object-oriented code. They look similar but are not interchangeable:

ER DiagramClass Diagram
ModelsDatabase tables and foreign keysClasses, methods, inheritance
RelationshipsCrow's foot cardinalityInheritance, composition, association
MethodsNoYes
Use whenDesigning/documenting a SQL databaseDesigning an OOP system in Java, Python, TypeScript

If you need to design the code layer, use the class diagram maker instead.