Make ER diagram
make_er_diagramUse this when the user wants an ER diagram, entity relationship diagram or database schema diagram drawn from SQL CREATE TABLE statements, for example "draw an ER diagram of this schema" or "make a PDF of my database tables". Takes the DDL text, a dialect (auto, postgres, mysql, sqlite), a page size and an optional title. Reads CREATE TABLE with columns, types, NOT NULL, PRIMARY KEY, UNIQUE and REFERENCES / FOREIGN KEY, including composite keys; lists every other statement as skipped with its line number. Returns counts, relationships with crow's foot cardinality taken from the DDL, schema problems, a geometry check (overlapping tables, lines crossing a table), the PDF page count and smallest text size, an interactive diagram, and PDF, SVG, CSV and JSON downloads. Refuses a CREATE TABLE that does not parse, naming the line. Up to 50 tables. Does not connect to a database or run SQL. Download links of large diagrams expire after about 1 hour.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ddl | Yes | The SQL DDL text: CREATE TABLE statements with columns, types, NOT NULL, PRIMARY KEY, UNIQUE and REFERENCES / FOREIGN KEY, up to 200,000 characters, e.g. "CREATE TABLE users (id int PRIMARY KEY, email text NOT NULL UNIQUE); CREATE TABLE orders (id int PRIMARY KEY, user_id int NOT NULL REFERENCES users(id));". Other statements are listed as skipped. | |
| title | No | Title printed on the diagram and used in file names, up to 80 characters, e.g. "Shop database". | |
| dialect | No | Which SQL quoting and type names to read: auto (default; accepts "x", `x` and [x]), postgres, mysql or sqlite. It also sets how names are matched: postgres folds unquoted names to lower case and keeps quoted names exact; the others ignore case. Example: postgres. | |
| page_size | No | PDF page: letter (default), a4 or tabloid (11 x 17 in). Landscape unless portrait needs fewer pages. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes | |||
| shown | No | ||
| title | Yes | ||
| counts | Yes | ||
| issues | Yes | ||
| tables | Yes | ||
| dialect | Yes | ||
| skipped | Yes | ||
| warnings | Yes | ||
| downloads | Yes | ||
| name_rule | Yes | ||
| layout_check | Yes | ||
| relationships | Yes | ||
| cardinality_rules | Yes |