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.
| Database | Is the child column indexed for you? | What to add |
| PostgreSQL | No | CREATE INDEX ON orders (customer_id); |
| MySQL, InnoDB | Yes, an index is created automatically if none exists | Nothing, but check the index is not redundant with another |
| SQLite | No | An 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.