ER diagram tool
Tables you edit as text, relationship lines in crow's foot notation, and a one-paste import from CREATE TABLE statements.
ER diagram symbols
Most teams draw tables with crow's foot lines. The Chen notation shapes, used in database courses, are included as well.
| Symbol | Name | Meaning |
|---|---|---|
| Table (entity) | Table (entity)The name on top, then one column per line: name, type, and PK or FK. Primary keys are shown in bold. | |
| Entity (Chen) | Entity (Chen)A thing you store data about. | |
| Attribute (Chen) | Attribute (Chen)A property of an entity. | |
| Relationship (Chen) | Relationship (Chen)How two entities are related, named with a verb. |
Crow's foot notation
Each end of a relationship line says how many rows on that side can relate to one row on the other. Read the symbol nearest a table as "how many of these".
| Line | Name | Meaning |
|---|---|---|
| One to many | One to manyOne row on the left relates to one or more on the right. A customer has one or more addresses. | |
| One to zero or many | One to zero or manyThe many side is optional. A customer has zero or more orders. This is what a nullable-free foreign key gives you. | |
| One to one | One to oneExactly one on each side. A user has one profile. | |
| One to zero or one | One to zero or oneThe right side is optional. An order has at most one refund. | |
| Many to many | Many to manyMany on both sides. In a real schema this becomes a join table with two one-to-many lines. |
How to draw one
Paste your schema into the SQL to ER diagram tool, or open the editor with the ER shapes and add a table.
Double-click a table to edit it: the name on the first line, then one column per line with its type.
Connect two tables, select the line and choose the relationship, such as one to many.
Drag tables to group them by domain, then export for your documentation.
Start from the schema you already have
If the database exists, do not redraw it. Paste the output of pg_dump --schema-only or mysqldump --no-data into the SQL to ER diagram tool. It reads tables, columns, primary keys and foreign keys, draws every relationship with crow's feet, and opens in the editor for rearranging.
Tables are text
A table is one shape. Editing it is editing a few lines of text, so adding a column is typing a line and renaming a table is changing the first one. The box resizes to fit.
Reading cardinality
Two marks sit at each end of a line. The outer one is the maximum: a bar for one, a crow's foot for many. The inner one is the minimum: a bar for at least one, a circle for zero. So a circle and a crow's foot means zero or many.
ER diagram templates
ER diagram guides
- Data modeling
Crow's foot notation explained: reading cardinality in ER diagrams
How to read and draw crow's foot notation: the four line endings, which end to read, how each maps to foreign keys, NOT NULL and UNIQUE in SQL, and the mistakes that model the wrong rule. - UML
UML class diagram relationships: association, aggregation, composition and the rest
The six UML class diagram relationships, the line and arrowhead for each, what they mean in code, how to read multiplicity, and when aggregation is worth drawing at all.
Questions
- Can it generate the diagram from my database?
- From its schema, yes. Paste CREATE TABLE statements into the SQL to ER diagram tool. It works from text, so it never needs a database connection or credentials.
- Can I export SQL from a diagram?
- No. The editor exports images, draw.io files and JSON. It reads SQL but does not write it.
- What is crow's foot notation?
- A way of drawing relationship lines where the line ending shows cardinality: a three-pronged "crow's foot" means many, a bar means one and a circle means zero. It is the most widely used notation for relational database diagrams.