ErdDocs

Schema diagram

A schema diagram is a picture of a database as it is actually built. Every table is a box, every column shows its type, and a line appears wherever one table references another. Paste the schema you already have and it is drawn for you, in any of ten formats. There is no database connection, and nothing leaves your browser.

Your schema

An airline booking schema. Paste yours over it, or drop a file onto the panel.

Schema diagram of an airline booking database: airports, aircraft, flights, passengers, bookings and the booking_legs join table, with crow’s foot marks showing which side holds each foreign key.Schema diagram of an airline booking database: airports, aircraft, flights, passengers, bookings and the booking_legs join table, with crow’s foot marks showing which side holds each foreign key.
The same airline booking schema, exactly as the SVG export draws it.

Schema diagram vs. ER diagram: is it the same thing?

Not originally, though in everyday use the two names have collapsed into one. An entity-relationship diagram, in the sense Peter Chen defined it in 1976, is a modeling artifact. It describes entities and relationships before anyone decides how to store them. A many-to-many relationship there is a single diamond with no foreign key anywhere, because foreign keys are an implementation detail that has not happened yet. A schema diagram describes what was built instead. The diamond has become a join table, such as a booking_legs table holding one row per flight leg of a booking. A conceptual model would never draw that table, and a real database cannot work without it. Most products sold as “ER diagram tools” draw schema diagrams with crow’s foot marks, not Chen diagrams. ErdDocs always does, because it reads a schema.

ER diagram (Chen, 1976)Schema diagram
Representsa concept, before storage decisionsthe tables a database actually holds
Many-to-manyone diamonda join table, e.g. booking_legs
Foreign keysnone, not decided yetshown, with crow’s foot marks
Made bydrawing, before the schema existsgenerating, from a schema that exists
Goes stale whenrequirements changenever: regenerate by pasting again

Two steps, and neither is drawing

  1. 01Get the schema as text. From a live database that is pg_dump --schema-only or mysqldump --no-data. In a project it is already there, as a Prisma schema, a migrations folder or the ORM model files.
  2. 02Paste it. The format is detected as you type and the diagram appears. Drag boxes if the arrangement matters, then export PNG or SVG, or switch to Data Dictionary for the printable written version.

What the diagram tells you about each table

Everything a schema states about structure, and nothing it does not:

  • Columns with their real types. char(3), timestamptz, varchar(120) appear as they were written, not flattened into a generic “string”.
  • Keys, including composite ones. The primary key of booking_legs is the pair of columns. That is what makes it a join table rather than a table that happens to have two references.
  • Which end holds the key. Crow’s foot marks put the many side where the foreign key actually lives, so the direction is readable without opening the DDL.
  • Declared versus guessed relations. A line the database really constrains is solid. Some schemas declare no foreign keys at all, so lines are recovered from column naming. Those are dashed and stay dashed.
  • Two references to the same table. flights points at airports twice, for origin and destination, and both lines are drawn rather than merged into one.

Why generate it instead of drawing it?

A drawn diagram is correct on the day it is drawn. The next migration makes it wrong, and nothing tells you. The picture keeps looking authoritative while the database moves underneath it. The diagram in a wiki is usually eighteen months old.

A generated diagram has no such gap. ErdDocs produces it from the schema itself, so redoing it costs one paste. If the schema already exists, drawing it by hand is copying a document you already own. Designing something that does not exist yet is the other job, and a drawing tool is the right instrument for it. What ErdDocs adds over one of them is on the ERDPlus alternative page.

FAQ

What is a schema diagram?

A schema diagram is a picture of a database as it is actually built. Every table is a box, every column shows its type, and a line appears wherever one table references another. It describes the physical structure, meaning what the server would create, rather than an idea of the data. So it can be generated from a schema file instead of drawn by hand.

Is a schema diagram the same as an ER diagram?

Not originally, though almost everyone now uses the words interchangeably. A true entity-relationship diagram, in the sense Peter Chen defined in 1976, models entities and relationships before any decision about tables. In it, a many-to-many relationship is a diamond, and no foreign key exists yet. A schema diagram shows the tables that resulted, including the join table that many-to-many actually became. Most tools sold as “ER diagram tools” draw schema diagrams. ErdDocs always does, because it reads a schema.

Can it draw a diagram of a database I have no connection to?

That is the normal case here. ErdDocs never connects to a server. The input is text: a dump, a Prisma schema, a folder of migrations, or ORM model files. That is what you have when the schema arrived by email, sits in a repository you cloned, or belongs to a client whose credentials you will never hold.

What does the diagram show about each column?

The name, the type as it was written, whether it is nullable, and whether it is a primary or foreign key. Relations carry crow’s foot marks, so the side that holds the key is visible at a glance. Relations recovered from column naming rather than a declared constraint are drawn dashed. The picture never claims the database says something it does not.

Which formats can it read?

ErdDocs reads ten formats. There is SQL from PostgreSQL, MySQL, SQL Server and SQLite, plus Prisma schemas, DBML, Mermaid and PlantUML. It also reads the model files of Django, SQLAlchemy, Sequelize and TypeORM, and a folder of Laravel migrations replayed in order. The format is detected from the text, so pasting is usually the whole procedure.

Is it free?

Diagrams up to 25 tables render in full for free, with no account, and PNG and SVG exports are free as well. Larger schemas are still parsed completely. The tables past the limit appear as locked placeholders, so you can see the shape. $9 once lifts the limit and unlocks the printable data dictionary.

Related