Skip to content

Draw an ER diagram

An ER diagram draws the tables of a connection with their columns and the foreign keys between them, laid out so that referenced tables stand to the left. ER diagrams with export: Works.

  1. In the Database tool window, select a connection, a folder or a table.
  2. Right-click and choose Diagrams › Show Diagram, or press ⌥⇧⌘U (CtrlAltShiftU). Tools › Database › Show ER Diagram does the same.

On a connection the diagram shows all tables and views; on a table it shows that table and the tables it references or is referenced by. The diagram opens fitted to the window.

  • Each box is a table: its name, then one line per column with type and the marks PK, FK and UK. Views have a dashed border and dashed lines to the tables they use.
  • Each line is a foreign key, labelled with its columns, for example warehouse_id:id. The ends show the cardinality: 1 or 0..1 at the referenced table, N or 1 at the referencing one.
  • Lines are routed around boxes. The layout is the same each time for the same schema.
  • Drag a box to move it. Layout (⌥L) puts every box back in place. Positions last while the diagram is open.
  • Zoom from 25 % to 400 %: ⌘= and ⌘-, ⌘0 for 100 %, ⇧⌘0 to fit, or ⌘ with the mouse wheel.
  • Tab and ⇧Tab move from box to box.

Press ⌥E or open the Export menu and choose a format:

Format File
Mermaid .mmd
PlantUML .puml
Graphviz DOT .dot
SVG .svg
PNG 1×, 2×, 4× .png, .2x.png, .4x.png
yEd GraphML .graphml
draw.io .drawio

Files go to .ferris-idea/diagrams/<connection>.<extension>. The text formats are also copied to the clipboard, ready to paste into a Markdown file that renders Mermaid. Everything is drawn on your machine; no web service is involved.

No diagram of a hand-picked set of tables, no saved positions across sessions, no switches to hide columns or keys, no routines, and no editing of the schema from the diagram.

er_diagram returns the same diagram in any of the formats above, or as JSON with the layout. It needs read-schema; writing a PNG file also needs the right write.

  • er_diagramchangessshwritedatabase-permissiontrusted-projectEntity-relationship diagram of a connection's tables and views: columns with PK/FK/UK marks, foreign keys with cardinality, what views use, and foreign keys leaving the selection.