Chapter 30
ER Diagram Modeler
Reverse-engineer a schema into an entity-relationship diagram, edit it, and forward-engineer DDL.
#30.1Generating a diagram
Pick a Schema and press Generate. DBCraft reads the tables, their columns, and the foreign-key relationships, and lays out the diagram automatically.
Generation is limited to the first 15 tables for performance. The empty-state message says so.
#30.2The toolbar
| Control | Purpose |
|---|---|
| Schema | Which schema to read. |
| Generate | Build the diagram. |
| Layout | Choose the automatic layout algorithm; changing it re-lays out an existing diagram. |
| Zoom in / Zoom out / Fit to view | Navigation. |
| Export DDL | Downloads schema.sql (see §30.5). |
| Toggle overview | Shows or hides the minimap. |
| Find table… | Type a name and press Enter — the canvas pans and zooms to that table. |
#30.3Editing the model
The diagram is not a static picture:
- Rename a table by editing its title.
- Edit a column — name, data type, length, nullability, primary-key flag.
- Add and delete columns.
- Delete a table.
- Add Table (the panel at the bottom of the canvas) creates
NEW_TABLE_nwith anIDprimary key. - Draw a relationship by dragging from one column’s handle to another. The source column is marked as a foreign key automatically.
- Click a relationship label to cycle its cardinality; delete it from the same control.
#30.4The display panel
Down the right side:
Display Options
- All Tables / Specified Tables — with Specified, a checklist lets you show or hide each table individually.
- Referenced Only — hides tables that participate in no relationship.
Graph Controls
- View — Graph (the canvas) or List (a compact textual outline: each table with its columns, key icons, types and nullability, plus the tables it references).
- Animate Layout — smooth transitions when the layout changes.
- Links to Columns — attach relationship lines to the specific columns rather than the table box.
- Show Link Name — label each relationship.
- Highlight Links — hovering a column highlights every relationship it participates in, and the columns at the other end.
- Node Content — how much of each table to show.
- Show Data Type — include column types (disabled when node content is set to name only).
Overview — Docked Minimap toggle.
#30.5Exporting DDL
Export DDL generates a complete schema.sql:
- A
CREATE TABLEfor every table, with column definitions,NOT NULLwhere set, and aCONSTRAINT PK_<table> PRIMARY KEY (…)for the primary-key columns. - An
ALTER TABLE … ADD CONSTRAINT FK_… FOREIGN KEY … REFERENCES …for every relationship.
This includes your edits, so the modeler doubles as a schema design tool.
#30.6Status bar
Along the bottom: current zoom percentage, the number of visible Tables, the number of References, and the engine and schema.