Schema ERD
Under Schema → Schema ERD, DB Studio draws an entity-relationship diagram of a connection's live schema: its tables and views, and the foreign keys between them. Use it to find your way around an unfamiliar database, to see how tables relate before you write a change, or to share a schema's shape as an SVG file. Any role can open it. It only reads the database; your arrangement of the diagram is kept in your browser, not on the server.
Supported Engines
- PostgreSQL (incl. CockroachDB, TimescaleDB)
- MySQL / MariaDB, the diagram shows the connection's database
- SQL Server
- Oracle, the tables, keys, indexes, views and sequences of the connection's schema (the user it signs in as, or the user picked as its database)
- SQLite
- Cassandra, the keyspace's tables with their partition and clustering keys, secondary indexes, materialized views and user-defined types
- Elasticsearch, each index is a table of its mapped fields (object fields as dotted names), and each alias a view of the indices it points to
- MongoDB, Neo4j and Redis, an approximate structure sampled from their data, without foreign keys. On Redis each table is a key pattern (numeric and UUID parts of a key become
*, souser:42anduser:43areuser:*), and a pattern of hashes lists its fields as columns.
The connection picker lists only connections of these engines, each with its engine after a middle dot. If the server cannot read a connection's engine, the ERD says so and names the engines it reads. If the list of engines cannot be loaded, the page says so with Retry, and the picker says connections are listed once the engines load.
Loading a Diagram
Pick a connection and choose Load ERD; Reload reads the schema again. Picking another connection clears the diagram until you load it. Above the diagram, a count gives the tables and views shown, the foreign keys drawn, and how many foreign keys point to tables outside the diagram, for example 22 tables · 8 views · 36 foreign keys.
What Is Drawn
- Tables are boxes showing their name, schema, and how many columns and foreign keys they have, such as 4 columns · 1 foreign key.
- Views and materialized views have rounded, dashed borders and an italic name, and say View or Materialized view.
- Foreign keys are arrows from the table that holds the key to the table it references, running border to border. Hover a line to see its columns.
- A foreign key that references its own table is a loop on that table's right side.
- Several foreign keys between the same two tables are drawn apart.
- A foreign key to a table in another schema, or one hidden by the schema filter, has no line; the count above the diagram includes it.
The Inspector
Click, tap or press Enter on a table or view to open it in the inspector. The inspector sits beside the diagram on wide screens and under it on narrower ones, such as a tablet or phone.
- Tables: columns with their types and NOT NULL, primary-key columns marked PK, unique constraints, indexes, the foreign keys the table holds (References) and the foreign keys in any schema that point at it (Referenced by). A related table's name is a link that takes the diagram to that table.
- Views: whether it is materialized, and its SQL definition.
Schema Filter and Search
When the database has more than one schema, the Schema filter limits the diagram to one of them, and the counts follow it. Find a table searches table and view names in every schema. Pick a match, or press Enter for the first one. The diagram then scrolls to it and opens it in the inspector, switching the schema filter if the match is in another schema. To narrow a search to one schema, type the schema name, a dot, then the table name.
Arranging the Diagram
Drag a table to move it. Your arrangement is saved in your browser for that connection and holds only the tables in its diagram. Tables added since are placed where they do not overlap the saved ones. Reset Layout returns the connection to the default grid. Arrangements are kept per browser, so another browser or another user starts from the grid.
Keyboard, Touch and Pen
- Every table and view can be reached with Tab. A screen reader announces its name, whether it is a table or a view, and its schema; for a table it also gives how many columns and foreign keys it has.
- With one focused, Enter or Space opens it in the inspector, and the arrow keys move it (hold Shift for bigger steps). Keyboard moves are saved like dragged ones.
- On a touch screen or with a pen, drag a table to move it and tap it to inspect it. Dragging a table does not scroll the page; dragging empty space scrolls the diagram.
Download
Download SVG saves the diagram as shown, with your arrangement and schema filter, as a standalone SVG file named after the connection (and the schema, when filtered). It opens in any browser or drawing tool.