Pikkola ERD, tool No. 75

Paste the DDL, see the schema.

A schema is easier to argue about when it is drawn. This page reads the CREATE TABLE statements you already have, works out which columns point at which, and lays the tables out so a foreign key always points right. The issues underneath are the ones that bite in production: a table with no key, a foreign key on the wrong type, a cascade that loops.

3
dialects
9
checks
0
uploads

The studio

One schema, four views

The diagram is the default. Issues, Mermaid, DBML and JSON read the same model, so what you export is what you checked, not a second parse.

Start from a sample
SQL, as you have it

It reads what you paste and nothing else. A pg_dump --schema-only, a SHOW CREATE TABLE or the migration in your repository all work; statements it does not know are counted, not guessed at.

What came out
Tables
0
Columns
0
Foreign keys
0
Dialect
generic
Issues
0

The counts update as you type. The issues tab lists every finding with the table and the column it belongs to.

100%

Drag a table to move it, drag the background to pan, scroll to zoom.

Table inspector

Column Type Null Key Default References

Pick a table in the diagram to read its columns here.

Text in, geometry out

No database connection, no diagram file to import. Three steps that stay inside the tab, in the order the page does them.

01

Read the statements

Comments are masked, strings and quoted names are respected, and each statement is split at the semicolons that are not inside a list. A CREATE TABLE gives its columns and constraints; ALTER TABLE adds the foreign keys a migration wrote later; CREATE INDEX is kept so a foreign key does not look unindexed when it is not.

02

Place the tables

A table with no foreign key of its own sits at the left, and a table that references it sits one column further right. Within a column the tables are stacked by name, and each column is centred against the tallest one. That is why the lines run left to right and cross rarely.

03

Check what breaks later

A primary key that is missing, a foreign key whose two sides are different types, a foreign key column no index covers, a SET NULL on a NOT NULL column, a cascade that loops back. Each one names the table and column, and says what to change rather than only that something is wrong.

What it reads, and what it leaves alone

The list is short on purpose. A parser that claims every dialect of SQL is a parser that guesses, and a guessed diagram is worse than none.

Statement or clause What it becomes Worth knowing
CREATE TABLEA box with one row per columnInline PRIMARY KEY, UNIQUE, NOT NULL, DEFAULT and REFERENCES are read from the column line
PRIMARY KEY (a, b)A composite key, marked on both rowsA table whose key comes only from a table constraint still counts as keyed
FOREIGN KEY ... REFERENCESA line from the child column to the parent columnTable constraints and inline REFERENCES both work, with or without a name
ALTER TABLE ... ADD CONSTRAINTA foreign key added to a table already readADD PRIMARY KEY, ADD UNIQUE and ADD COLUMN are read too
CREATE INDEX / CREATE UNIQUE INDEXAn index the checks can seeA foreign key is only reported as unindexed when no index starts with its column
CHECK, ENUM, domains, viewsCounted, not drawnA CHECK expression is database logic, and this page draws relationships, not rules
INSERT, SELECT, GRANTSkippedA file that mixes data and schema still works; the data statements are counted as other

Two things it deliberately does not do: it does not resolve the database's real types, and it does not fetch a schema from a server. It reads the text in front of it.

Field guide

A schema you did not write, read in ten minutes

Most of the time the diagram is not for you. It is for the person who has to change a table next month, or for the pull request that adds one. The order below is the one that finds the expensive mistakes first.

Start from the keys, not the boxes

A table without a primary key is the first thing to look for, because every other problem downstream of it is harder to fix. Without a key, a duplicate row is legal, an update cannot name its target, and a foreign key cannot point at it at all. The issues panel puts this first for that reason. After the keys, read the unique constraints: a unique index on an email column is what actually enforces the rule, and an application check alone is a promise, not a constraint.

Every foreign key needs an index on the child

PostgreSQL does not index the referencing side of a foreign key. The parent side is covered, because it must be unique. That asymmetry is why deleting a parent row can take a lock scan on the whole child table, and why a cascade delete that looked instant in development crawls on a table with ten million rows. The check here is narrow on purpose: it looks for an index whose first column is the foreign key column, which is the shape the planner needs.

DatabaseIs the child column indexed for you?What to add
PostgreSQLNoCREATE INDEX ON orders (customer_id);
MySQL, InnoDBYes, an index is created automatically if none existsNothing, but check the index is not redundant with another
SQLiteNoAn explicit index, if the child table is large

The two sides of a foreign key must agree on type

A varchar(36) pointing at an integer is the classic. It works in a database that casts quietly, fails in one that does not, and turns every join into a conversion that cannot use an index. The comparison here is by family, not by spelling: integer and bigint are the same family and pass, uuid and text do not. That is deliberate. A mismatched width is a judgement call about future growth, while a mismatched family is almost always a mistake.

Read the delete rules together

ON DELETE CASCADE is a promise that a delete will propagate, and it is the right promise for an order item that cannot exist without its order. It is the wrong promise on an audit log, where the history is the point. The check that matters most is the loop: two tables that cascade into each other mean a delete that has to finish in one transaction can never finish. The page reports a cascade cycle as a warning and names the tables in the loop.

ON DELETE SET NULL on a column declared NOT NULL is a constraint that will fail at the worst possible moment, so it is reported as a warning as well. The fix is either to allow null or to choose CASCADE or RESTRICT on purpose.

What a diagram cannot tell you

  • Cardinality in practice. A foreign key says a row may point at one parent. It does not say how many children a parent usually has, and a one-to-one relationship is only visible through a unique constraint on the child column.
  • Nullability intent. The optional circle is the database's rule, not the product's: a nullable customer_id on an order may mean guest checkout, or it may mean someone forgot the constraint.
  • Indexes you cannot see. A read from a managed service may not include every index. The unindexed warning is therefore a question, not a verdict.
  • Views and functions. A schema is more than its tables, and only the tables are drawn.

Taking the drawing somewhere else

Three exports, three jobs. SVG is for a document that should stay sharp and searchable, and it keeps the text as text. PNG at twice the size is for a chat window that will not accept anything else. Mermaid is for a Markdown file that lives beside the migrations, so the diagram moves with the code in review; DBML is for dbdiagram and for the tools that read it. All three are written from the parsed model rather than from the canvas, so a table dragged into a tidier place does not change a line of the output.

For the statements themselves, Pikkola SQL formats the same DDL and writes TypeScript, Zod, Prisma or Pydantic models from it. To check what an API says about the same data, Pikkola OpenAPI reads the specification.

Questions

Is my schema sent anywhere?

No. The parser is a function in a JavaScript file on this domain, and the page's Content-Security-Policy allows no connection except the cookieless page-view counter. The SQL stays in the tab, and once the page has loaded it keeps working with the network off.

Which databases does it understand?

PostgreSQL, MySQL and SQLite DDL, decided from what the text contains: SERIAL and jsonb point to PostgreSQL, AUTO_INCREMENT, backticks and ENGINE= point to MySQL, AUTOINCREMENT and WITHOUT ROWID to SQLite. The dialect changes which checks run, not how the boxes are drawn.

Does it connect to my database?

It cannot. There is no driver and no connection, only the text you paste. A pg_dump --schema-only, a SHOW CREATE TABLE, or the migration file in your repository is the input it expects.

Why is a line drawn from that column?

The line leaves the child at the first column named in the foreign key and arrives at the parent at the referenced column. For a composite key the first pair is used for the line and the rest are listed in the inspector under the diagram, where the whole key is visible.

What does the circle on a line mean?

It means the child column accepts null, so the relationship is optional. No circle means NOT NULL, so every row must point at a parent. The crow's foot is on the child side, because a parent can have many children.

Can a diagram be too large to read?

Yes. Past about forty tables, a single page stops being a diagram and becomes a map. The search box dims everything that does not match, which is usually enough to read one corner of a large schema at a time, and the exports keep the whole thing for whoever needs it.