Help home > ER Diagrams and Table Specifications

ER Diagrams and Table Specifications

Create ER diagrams from the foreign keys in your database and export them as images or PDF. You can also produce table specifications (Excel or HTML).

What you can do

TaskHow to open
Create an ER diagram of every table in a schemaRight-click a schema in the tree and choose "Create ER Diagram (All Tables)"
Create an empty ER diagram🔗 New ER diagram in the top bar
Open a saved ER diagram"File" → "Open ER Diagram..." in the menu
Table specificationRight-click a schema or table in the tree and choose "Export Table Definition Document (Excel / HTML)...", or use Export ▾ in the ER diagram
Text for AIRight-click a schema or table in the tree and choose "Copy Table Structure for AI...", or use Export ▾ in the ER diagram

Getting started: creating an ER diagram (3 steps)

  1. Open an ER diagram

    Right-click a schema in the tree and choose "Create ER Diagram (All Tables)". Tables are arranged automatically, with parent tables above child tables.
  2. Tidy up the layout

    Drag tables to move them. Auto Layout rearranges them, and Fit to Window zooms so the whole diagram is visible.
  3. Export

    Choose SVG, PDF or clipboard from Export ▾.

Adding tables

ConnectionAn ER diagram works with the tables of one connection (database). You can change the connection in the list at the top left. An empty ER diagram takes the connection of the first table you add. You can't add tables from another connection.

Reading the lines (IE notation)

Table border Zero or More (0..N)One or More (1..N)Zero or One (0..1)Exactly One (1)
End symbols of a line (the vertical line on the left is the table border). A crow's foot means "many", a bar means "one" and a circle means "zero". The symbol nearest the table is the maximum; the one farther away is the minimum.

Choose the line shape with Lines: Straight / Lines: Right-angled in the toolbar. "Right-angled" routes lines horizontally and vertically, going around any entities in the way. Musubi SQL also picks the sides and positions where lines enter and leave so that lines cross each other and end symbols overlap as little as possible (the chosen shape is saved with the ER diagram). Where two lines cross, one of them hops over the other with a semicircle, so you can tell a crossing from a connection (with right-angled lines, the horizontal line hops).

How cardinality is determined: By default, cardinality is derived from the foreign key columns as follows. In a table, PK marks primary key columns and FK marks foreign key columns.

EndAutomatic cardinality
Parent (referenced side)"Exactly One" if the foreign key columns are NOT NULL; "Zero or One" if they allow NULL
Child (side with the foreign key)"Zero or One" (one-to-one) if the foreign key columns are a primary key or unique index; otherwise "Zero or More"

Operations

ActionResult
Drag a tableMoves it (snaps to a 10-unit grid)
Ctrl+dragSelects the tables, text and callouts in the rectangle (anything touching the rectangle is added to the current selection). Ctrl+click selects or deselects one item at a time
Drag a multiple selectionMoves them together, keeping their arrangement. Delete removes them all; Esc or clicking the background clears the selection
Drag the background, mouse wheelPans the diagram
Ctrl+wheel, - +Zooms in and out
Double-click a tableOpens the table definition (for a new entity, the designer)
Delete, or right-click → "Remove from ER Diagram"Removes it from the ER diagram (the database table is not deleted)
Ctrl+Z, ↶Undo (adding, removing and moving tables, auto layout, applying designs). Ctrl+Y or ↷ redoes
Hover over a lineHighlights the line in blue and the tables at both ends in orange, so you can tell overlapping lines apart
Hover over or click a tableHighlights the table in blue and the connected tables and lines in orange (when you move the mouse away, the relationships of the selected table are shown)
Display names, Types, Keys onlySwitches between logical names, physical names and both (Ctrl+L), shows data types, and shows only primary key and foreign key columns. These are per-diagram settings, separate from the app-wide display names
Hide common columnsHides the common columns (created at, updated by and so on) defined in the connection settings. Foreign key lines made only of common columns (such as CreatedBy → User) aren't drawn either. Primary key columns stay visible. Saved per diagram. When common columns are shown, their names are drawn in a greenish color to set them apart
Auto LayoutRearranges tables with parents (referenced side) above and children below. Children are placed directly under their parent and parents are centered over their children, so lines run vertically and horizontally as much as possible
Reload from DBReloads the table definitions

New entities and DDL

+ New Entity adds a table that doesn't exist in the database yet (with a yellow header). Double-click it to open the designer (see Creating a table in the GUI), and click Apply to ER Diagram to bring it back into the diagram. Generate DDL creates the DDL for the new entities in a SQL tab, or for every table in the diagram if there are no new entities.

Creating and deleting relationships

  1. Click Create Relationship (or right-click an entity and choose "Create Relationship (Drag from Here to the Parent Table)").
  2. Drag from the child table (the side with the foreign key) to the parent table (the referenced side). Esc cancels.
  3. In the dialog, map the child table's columns to the parent table's columns. Columns matching the parent's primary key are selected automatically, and you can add columns the child lacks with "+ Create a new column".

SQLite can't add or drop foreign keys with ALTER (the table has to be recreated).

Virtual relationships (relationships without a foreign key constraint)

Define a relationship in the ER diagram only, without creating a foreign key constraint in the database. Use this to record relationships between tables where you don't want a constraint.

Text and callouts

Use + Text / Callout ▾ to add notes to the diagram. Line breaks are allowed (Ctrl+Enter confirms).

Page borders and per-page PDF

Page: A4 Landscape ▾ shows border lines that divide the diagram into print areas by paper size (page borders). The number at the top left of each border is the page number.

Export (SVG, PDF, clipboard)

From Export ▾, choose the area and the destination.

SVG fileClipboardPDF file
Whole Diagram○○○
Select Area○○○

Exports always have a white background regardless of the app theme (unless the background is transparent).

Saving and opening

ER diagrams are saved as .msqer files. Table definitions are saved with the diagram, so you can open it offline. Display names, Types, Keys only, Hide common columns, line shape, zoom and scroll position are also saved and restored the next time you open it (changing only the zoom or scroll position doesn't mark the diagram as unsaved).

Table specifications

Choose the tables, title, format (Excel or HTML) and items (indexes, foreign keys, Referenced by) to export.

ContentsExcelHTML
Table list (logical name, physical name, schema, type, description)First sheet (with links to each sheet)At the top (with links to each table)
Definition of each table (columns, indexes, foreign keys, Referenced by)One sheet per tableOne section per table (each table starts on a new page when printed)

The column table lists No, logical name, physical name, data type, NOT NULL, default, PK, description and remarks (auto increment, references). "Referenced by" lists foreign keys in other tables that reference this table (searched among the exported tables).

Text for AI

Choose "Text for AI" as the format to export text that tells an AI such as ChatGPT or Claude about your database structure, to the clipboard or a file (.sql). Paste it before your question, and the AI is more likely to write SQL with the right table names, column names and join conditions.

FAQ

A table shows "(Could not get the definition)"

The table doesn't exist in the ER diagram's connection. Check the connection in the list at the top left. Hover over the table to see the cause.

Lines don't appear

Lines aren't drawn when the table a foreign key references isn't in the ER diagram. Right-click and choose "Add Related Tables" to add it.

▲ Back to top

← Musubi SQL website (download)