Skip to main content
Right-click the empty space below the sidebar’s object list and choose View ER Diagram, or use Database > View ER Diagram. What opens is the current schema, drawn entirely from the foreign keys the driver reports: tables outside that schema are left out, and a foreign key pointing at one of them is not drawn.
ER diagramER diagram

ER diagram showing tables and foreign key relationships

After a change made elsewhere, click Refresh in the diagram’s toolbar or press Cmd+R. Every table stays where it is, and a table that is new since the last load is placed to the right of the others.

Reading the diagram

Each node lists the table’s columns with their types and badges the primary and foreign keys. Tables connected by foreign keys share a header color; a table with no relationships stays uncolored. With the system Differentiate Without Color setting on, the tint goes and grouping is left to position. Each relationship line runs from the row of the foreign key column to the row of the column it references, so two keys between the same tables leave from their own rows. A composite key, such as (order_id, line_no), fans its rows into one line on each table. Tables side by side join on the edges that face each other. Tables stacked one above the other join on their right edges, with the line looping out past them. Edges use crow’s foot notation. The referenced end always carries a single bar, “exactly one”. The foreign key end shows the cardinality inferred from the key’s columns and the table’s primary key and unique indexes, so an edge from orders.user_id to users.id forks at orders and bars at users. A composite key is unique when its columns hold the whole primary key or a whole unique index, and nullable when any of its columns is. A foreign key that points at its own table, employees.manager_id to employees.id, is drawn as a loop out of the table’s right edge, from the key’s row back to the referenced row, with the same two markers. Hold the pointer over a line to highlight the rows it joins on both tables. A help tag names the constraint and lists its column pairs, orders.customer_id → customers.id, and says when a staged key is not saved yet. Click a line to select it: its rows stay highlighted until you click elsewhere.

Column connections

Connect to Columns, the connected-dots button in the toolbar, is on by default. Turn it off to have every line meet the edges of its tables rather than their rows, which can read more easily on a crowded schema. Hovering and selecting a line still highlight its rows. A row the diagram does not draw has no place for a line to end. A key column or referenced column that compact mode hides, and the many-to-many line of a collapsed junction table, meet the table at its name. The buttons and keyboard commands step through fixed levels from 5% to 300%. A pinch, Cmd + scroll and Fit reach 1%. The keyboard commands act on the diagram while it has focus. Opening or returning to the tab gives it focus unless the sidebar or another pane holds it, and a click anywhere in the diagram takes it back. Drag a node to move it, toward the edge of the viewport to auto-scroll. Positions are saved and survive across sessions; Reset Layout, the circular arrow button, puts every table back where the automatic layout had it. VoiceOver reads the diagram as a layout area of tables. Each table announces its name, its column count and what it is joined to; step into one to hear each column with its type, whether it is a primary key or a foreign key and which column it references, and whether it is optional. Selecting a table in the diagram moves the VoiceOver cursor to it. VO-Shift-M on a table or a column opens its menu.

Editing the schema

Right-click a table, a column, a relationship or the empty canvas for what applies there. Double-click a table to open its rows in a new tab. To add a foreign key, hover over the column that will hold it, drag from the dot on the table’s right edge, and drop on the column it references. A sheet confirms the column pairs, the constraint name and the ON DELETE and ON UPDATE actions. Add Foreign Key… in a column’s menu opens the same sheet without the drag. Each row of the sheet’s list pairs a Column of this table with a Referenced Column, and the rows are the key’s order on both sides. The sheet fills in the referenced table’s whole primary key, one row per key column, so a key on (order_id, line_no) arrives as two rows. Your column takes the key column you dropped on, or the one the sheet picks when you came from the menu, and each other key column gets a column of this table with the same name, or None where there is none. A drop on a column outside the primary key gives that one pair, and a referenced table without a primary key starts on its first column. Choosing another referenced table fills the rows again from its key. Click + under the list to add a pair and − or Delete to remove the selected ones; the last pair stays. Drag a row to reorder the pairs, or use Move Up and Move Down in VoiceOver. Add Foreign Key stays dimmed until every row names both columns and no column repeats, and the line under the list names the problem. To drop a foreign key, click its relationship line and press Delete. New Table… opens a Create Table tab on the diagram’s database and schema. Once the table is created, it appears in the diagram where you right-clicked.

Saving diagram edits

Nothing runs until you save. A key you add or drop is drawn dashed, red when dropped. A column you add is tinted green, a dropped one red and struck through, a renamed one yellow.
  • Preview SQL (Cmd+Shift+P) shows the statements, the same ones the table’s Structure tab builds for the same change.
  • Save Changes (Cmd+S) applies them one table at a time, in the order you first edited them, then reloads the diagram with every table in place. Each table’s save asks the way a Structure tab save does under Safe Mode, and on SQLite a key change is shown as a table rebuild to confirm first.
  • Cmd+Z undoes the last edit. Discard Changes in the diagram’s toolbar drops all of them.
Closing the tab or the window with edits staged asks to save them first. An item an engine cannot carry out is left out of the menu: on an engine that cannot add or remove foreign keys, the key items and the drag handle do not appear.

Build a join query

Command-click or Shift-click tables to select more than one. Click Build Join Query in the toolbar, or right-click a selected table and choose Build Join Query…, to open the Join Builder on them.

Compact mode

The compress button in the toolbar cuts every table down to its primary key and foreign key columns, which is what makes a wide schema fit on screen.

Junction tables

A table whose primary key is made of two foreign keys, user_roles and its like, is read as a many-to-many join. Collapse Junction Tables is on by default: the junction table is hidden and one many-to-many edge, forked at both ends, joins the two related tables. Turn it off to draw the junction table itself, with its two one-to-many edges and a distinct header icon. The toggle appears only when the schema has junction tables.

Export

Export, the last button in the toolbar, opens a menu of formats. Every format holds the whole diagram, whatever the current zoom and scroll position, and compact mode and expanded junction tables carry into it, so set the view up first. PNG, SVG and PDF keep the window’s colors and the table positions on screen. Mermaid and DOT list tables by name and columns in table order, so exporting an unchanged schema twice writes the same file and a diff shows only real changes. Copy as Mermaid puts the block on the clipboard inside a mermaid code fence, ready to paste into a GitHub comment or any Markdown that renders Mermaid. Cmd+C copies the PNG image, scaled down the same way. For a very large diagram at full size, export SVG or PDF. Mermaid accepts fewer characters in a type or column name than SQL does. A space, comma or quote becomes an underscore, so character varying(255) reads character_varying(255), and a column named pk, fk or uk gets a leading underscore. For the tables’ DDL, choose File > Export > Export Tables…, pick SQL and leave Structure on. See Import & Export.

Database support

Edges are drawn on MySQL, MariaDB, PostgreSQL, Redshift, CockroachDB, PGlite, SQLite, SQL Server, Oracle, DuckDB, Snowflake, libSQL, and Cloudflare D1. Every other driver reports no foreign keys at all, so the command still opens a diagram and every table in it arrives unconnected.