Studio edition /

Schema diagram

See the tables of one or more schemas and their foreign keys as a diagram you can arrange, filter and export. Studio edition.

On this page

Open it#

In the Studio edition, switch to Advanced and pick Schema in the sidebar. The diagram draws the public schema if there is one, otherwise every schema. Schemas to draw picks others; the choice stays in the address, so a diagram can be reloaded or shared.

The toolbar shows how many tables and relations are drawn.

What it draws#

  • A card per table, with its columns, their types, a key for the primary key and an arrow for foreign key columns. Columns that allow NULL are in a lighter color.
  • Partitioned tables once, as their parent; the partitions are not drawn. Foreign tables, views and materialized views appear too.
  • A line per pair of columns of each foreign key. A foreign key of two columns draws two lines.
  • Relations with tables of another schema that is not drawn are counted on the card (↗ and the number) instead of drawn.
  • Drag the background to move, and zoom with the wheel or the controls. The minimap shows where you are.
  • Fit to screen brings the whole diagram into view.
  • Click a card to highlight it, its relations and the tables next to it; the rest fades.
  • Filter tables keeps only the tables whose name contains the text. Enter centers the first one.
  • Compact shows only the table names, with one line per foreign key. It is on by default with more than 60 tables.

The menu of each card has Open data, Open structure and Open relations.

Arrange it#

Auto layout places each group of related tables from left to right, a table before the ones it references, and spreads a step with many tables over several columns, so a large schema fills the screen instead of one long column. The groups go in rows, the largest first and the tables without relations last. Drag a card to move it. The positions are saved in your browser, for each connection and set of schemas, and are there again when you come back.

Export#

Export offers:

  • SVG and PNG: an image of the diagram as you see it.
  • Copy as Mermaid: the tables, columns and foreign keys as a Mermaid erDiagram, copied to the clipboard, ready to paste into Markdown.

Large schemas#

The diagram is read with four queries to the catalog, without reading any data. It was tested with 300 tables: it opens in under two seconds, and moving and zooming stay smooth. With that many tables, filter by name or draw fewer schemas to find your way.

Permissions#

The diagram only reads the catalog, so any role can open it, and it works in read-only mode. It shows the tables PostgreSQL lists for that role.