ER diagram

Entities, their fields and the cardinality of every relationship.

1 er diagram example

E-commerce data model

Customers, orders, order lines and products with their cardinalities.

An ER diagram is entity-level: lines join boxes and carry cardinality at each end. Keys are marked in the field list, and the customer entity, the aggregate root of the model, carries the accent.

Open in the editor

What is an ER diagram?

An entity-relationship (ER) diagram models the data a system stores: the entities, such as Customer, Order and Product, their attributes, and how they relate. Peter Chen introduced it in 1976, and crow's foot notation is the most common style today.

Read each box as an entity and each line as a relationship. The symbols at the line ends give cardinality: a single bar means one, a crow's foot means many, and a circle means optional.

When to use an ER diagram

  • Use it to design the data model of a new product, such as an online store, before writing any SQL.
  • Use it to explain a domain to analysts or new engineers who need to know what connects to what.
  • If you need column types, indexes and foreign key names for a specific database, draw a database schema instead.

How to make a good ER diagram

  1. Name entities with singular nouns and relationships with verbs, like "Customer places Order".
  2. Mark cardinality on both ends of every relationship.
  3. List only the key attributes; the full field list belongs in the schema.
  4. Resolve many-to-many relationships with an associative entity, such as OrderItem.