How to make an ER diagram
An entity-relationship (ER) diagram is a picture of the data your system stores and how the pieces relate. It is the usual first step before designing database tables.
The building blocks
- Entity: a thing you keep data about, such as Customer, Book or Order. Drawn as a box.
- Attribute: a property of an entity, such as name, price or email. In Chen notation each attribute is an ellipse attached to its entity.
- Primary key (PK): the attribute, or set of attributes, that uniquely identifies each record.
- Foreign key (FK): an attribute that points to the primary key of another entity.
- Relationship: how two entities are connected, such as Customer places Order. Drawn as a diamond in Chen notation.
- Cardinality: how many of one side relate to the other: one to one (1:1), one to many (1:N) or many to many (N:M).
Step by step
- List the entities: the nouns your system has to remember.
- Add the attributes each entity needs, and choose a primary key for each.
- Find the relationships between entities, and name them with a verb.
- Set the cardinality on both sides of every relationship.
- Resolve many-to-many relationships with a linking entity that holds the two foreign keys.
- Review for duplication: if a fact is stored in two places, one of them probably belongs in its own entity.
A small example
A bookshop has Author, Book and Order. An Author writes many Books (1:N). A Book appears in many Orders and an Order contains many Books (N:M), so you add an OrderItem entity between them with the keys of both. Book has attributes isbn (PK), title and price; Order has id (PK), date and the customer reference.
Notations
Chen notation, with boxes, attribute ellipses and relationship diamonds, is the classic teaching format and shows every attribute explicitly. Crow's foot notation is common in tools for database design and puts the attributes inside the entity box. ExcaliClaw draws Chen notation.
Draw one in ExcaliClaw
You can draw it by hand on the canvas, or describe it to an AI assistant connected over MCP. The create_er_diagram tool takes your entities with their fields, mark primary and foreign keys, and your relationships with a label and cardinalities such as 1, N or 0..1. The server computes every position, so ellipses and lines do not collide.
Keep reading