ER Diagram Generator from SQL · Tutorial

How to draw an ER diagram of an existing database

8 min readbeginnerUpdated

You have joined a project with an existing database and no diagram. You will export the schema, paste it into the generator, read the relationships, and save the diagram for the team.

What you need

Steps

  1. Export the schema

    Dump only the structure, not the data. For PostgreSQL that is pg_dump --schema-only; for MySQL, mysqldump --no-data.

    pg_dump --schema-only --no-owner mydb > schema.sql
    mysqldump --no-data mydb > schema.sql
  2. Open the file

    Drop schema.sql onto the page or paste its contents. Load the example to see a small online shop: customers, addresses, products, orders and order items.

  3. Read the relationships

    A line from customers to orders with a fork at the orders end means one customer has many orders. The circle at the addresses end of shipping_address_id shows the column can be empty.

  4. Simplify a big schema

    For dozens of tables, untick Show columns to see only the structure, or tick Only key columns to keep the keys that explain each relationship.

  5. Share it

    Download a PNG for a ticket or slide, or copy the Mermaid code into the README, where GitHub draws it and it can be updated with each migration.

Try it yourself

Opens the ER Diagram Generator from SQL with this tutorial's sample loaded.

Try it now

Common mistakes

Missing relationships
Only real foreign keys are drawn. If the app links tables without them, the diagram shows the tables unconnected; that may be worth fixing in the database.
Pasting a full dump with data
INSERT statements are ignored but make the file huge. Export the schema only.

Next steps

Go back to the ER Diagram Generator from SQL, or keep going with one of these: