In this guide
BUILD TABLES VISUALLY
DB Diagram guide
Design tables visually, define keys and indexes, connect foreign keys, and save or export a relational database diagram.
Design tables directly on the database canvas
DB Diagram creates a relational schema from tables, columns, keys, and foreign-key relationships. Add and edit the model visually; SQL is an export of the design rather than the source you must maintain.
This is separate from SQL to ERD, which starts with SQL source, and ERD Builder, which models conceptual Chen and EER diagrams. A DB Diagram file does not overwrite a SQL workspace or a Chen model.
Build your first relational diagram
- Open DB Diagram and choose Blank database or Order database template. Select SQLite, PostgreSQL, MySQL, or SQL Server in the Database control before choosing types and defaults.
- Choose Add table. Its left editor opens with an id primary-key column. Rename the table, add columns, and enter each column’s name and type. Use the N and Key controls for nullability and primary-key membership.
- Add a second table with a matching foreign-key type. In that column’s actions, choose Connect to a key. Select the child column under From table and Foreign-key column, then choose the parent’s Referenced key.
- Arrange the tables and choose Review for optional design suggestions. Export SQL to inspect the generated definitions, or open them in a separate SQL workspace.
- Name the design and choose Save to keep a cloud file, signing in if prompted. Use File → Download JSON for an editable backup. Save again after later changes.
Tables, columns, and constraints
Use Add table to create a relational table. Table names must be distinct in the design; column names must be distinct within their table. Names are quoted in SQL output so spaces and reserved words are preserved.
The left panel is the table editor. Each table has its canvas color and a summary of its columns, primary-key columns and relationships. More actions stay visible; hover or keyboard focus reveals Rename and Locate, and touch screens keep them visible. Open a table by its name or chevron to edit column names and types inline. Enter or leaving a field commits a valid value; Escape restores its previous value. An incomplete or invalid edit stays visible with an explanation.
The N control allows NULL when active; turning it off requires a value. The Key control sets primary-key membership. Primary-key columns cannot allow NULL. Open a column’s actions, then Column options, to set Unique, Auto increment, or a Default value (SQL expression). Inline badges summarize defaults, uniqueness, auto-generated values and referenced keys.
Selecting or editing a table in the left panel highlights its canvas card without changing zoom or pan. Use Locate to center it deliberately. Selecting or dragging a canvas table highlights it without expanding the left editor or switching phone panels. Use its pencil icon to open the editor, or double-click a canvas column to reach that row. Selecting another canvas table keeps the current editor open until you deliberately open another or collapse it.
Drag a column’s grip to reorder rows inside its table, or choose Move column up / Move column down from its actions. Reordering changes the definition order while keeping relationships attached. Menus open beside the selected item and close when you click outside.
Table actions include duplicate, delete, comments, and indexes. Duplicate creates a separately editable table with new IDs and an unused name, retaining its column definitions, indexes, comment, color, relative layout, and self-referencing relationships. It does not clone relationships to other tables.
Duplicate column appears in a column’s actions. It places the copy immediately after the original and focuses its new, unused name. Type, SQL default, nullability and uniqueness are retained; primary-key and auto-increment flags, relationships and named-index membership stay on the original. Types and defaults keep their native behavior, so PostgreSQL SERIAL still generates values.
Click a referenced-key badge to jump to its exact table and column without changing diagram zoom or pan. A search that was hiding the destination is cleared. You can follow references in shared read-only designs too.
A primary key identifies a row. Foreign keys use stable table and column identities, so renaming an endpoint keeps the connection attached. Deleting a table or column removes its affected relationships; review the action before confirming it.
Choose types appropriate for the selected dialect. A diagram expresses the intended design; review the exported SQL and validate it against your own database before deployment.
Choose types and default expressions
Open the Type dropdown to search suggestions for the selected database, or enter a custom type. Column options add comments and validation rules: numeric range, text length, or allowed text values. Bounds are inclusive; NULL is controlled separately. Rules and comments are saved and exported with the column.
Enter only a data type in the Type field, such as INTEGER, VARCHAR(120), or DECIMAL(10,2). Suggestions are a starting point; other type names can be entered. Keep PRIMARY KEY, NOT NULL, UNIQUE and DEFAULT in their separate controls rather than appending them to the type.
Default value accepts a SQL expression. Use 0 for a number, CURRENT_TIMESTAMP for a timestamp, or single quotes around text, such as 'pending'. Leave the field blank for no default. A default supplies a value when an INSERT omits the column; it does not restrict the values that can be stored.
Auto increment requires a single integer primary key and cannot also use a default expression. SQLite requires the INTEGER type for this option. MySQL integer types can be UNSIGNED; referenced and referencing types must still match. PostgreSQL SERIAL and other native type or default expressions retain their own database behavior even when the separate Auto increment flag is off.
Changing Database validates the current model against that dialect. Existing types and default expressions are preserved rather than rewritten automatically. If a key, name or relationship action is unsupported, the current design stays intact and the message explains what to adjust.
The canvas column form keeps exact default expressions, including quoted function or schema names. If a column clause cannot be retained by this visual model, such as a custom identity seed or ON CONFLICT behavior, it explains the limitation instead of removing that rule. Keep those definitions in the SQL workspace when you need them.
Review optional design suggestions
Choose Review above the table list to inspect suggestions for empty tables, absent primary keys, unindexed foreign-key columns and exact duplicate index definitions. Select a suggestion to reveal its table, column or index in the left panel without moving the canvas camera.
These suggestions are optional. Tables without primary keys can be intentional, and index choices depend on your workload. Review does not rewrite the model or add extra restrictions to saving or exporting. No suggestions means only that these particular checks found nothing to review.
For foreign-key lookups, a primary key, unique column or named index covers its leading column. A later column in a composite key or index alone does not provide that prefix. MySQL supplies supporting foreign-key indexes automatically, so this review skips that suggestion there.
Open an index suggestion to focus the matching index row, then choose whether to edit or remove it using the existing controls. Changes support Undo and the review updates as you work.
Describe the table and define real indexes
Use the table’s Comment field to describe its purpose. The comment is saved with the editable model and included in SQL export using the chosen dialect’s native comment syntax.
Add an index from the expanded table editor. Name it, choose one or more columns in order, and decide whether it is unique. These are saved schema objects and become CREATE INDEX or CREATE UNIQUE INDEX statements in SQL export; an index label is not a substitute for an actual index definition.
A normal index can help queries find data. A unique index additionally constrains the indexed values. Choose column order to match your query requirements, and review target-database behavior for NULL values and type limits. Expression indexes and partial-index predicates are not modeled here.
A table supports up to 50 indexes; a design supports up to 1,000 indexes. Table comments support up to 2,000 characters. Removing an indexed column removes it from each affected index and removes an index when it has no columns left.
A single-column unique index can qualify its column as a referenced key. A multi-column unique index does not make each column individually unique. Removing the only qualifying unique key used by a foreign key is rejected; change or remove the dependent relationship deliberately first.
Connect foreign keys in the right direction
The referencing column belongs to the child table. The referenced primary or unique key belongs to the parent table. For example, orders.customer_id references customers.id.
Choose Relationship above the canvas, Add relationship in an expanded table, Connect to a key in a column’s actions, or drag between column edges on the canvas. The form offers compatible existing keys. Referencing and referenced columns need matching types, including relevant width, scale and modifiers; recognized aliases such as INT and INTEGER are treated consistently.
A relationship can connect one column or several column pairs. Choose a complete primary or unique referenced key, then review the suggested matches. A composite key is one relationship, not separate single-column keys.
Use Edit relationship in the table’s Relationships section to change all pairs together. Deleting any participating column or connector removes the whole relationship; Undo restores it.
A foreign key does not by itself make a child value required or unique. Turn off NULL to require a parent for each child; add Unique only when the same parent key must not appear in more than one child row. Neither setting requires every parent to have a child.
Open Relationships in an expanded table and expand a connection to choose On delete or On update. NO ACTION is the default. CASCADE, RESTRICT, SET NULL and SET DEFAULT are available subject to the selected dialect and model: SQL Server uses NO ACTION instead of RESTRICT; MySQL does not support SET DEFAULT; SET NULL needs a nullable child column; SET DEFAULT needs its default expression. Defaults and cascading paths still need review in the target database.
Renaming either endpoint keeps its connection. Delete relationship removes the connection while keeping both columns; deleting a table or column also removes the connections that use it.
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE orders (
id INTEGER PRIMARY KEY,
customer_id INTEGER,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);Arrange and navigate without changing the schema
Drag table headers to move tables. Use zoom and Fit to Screen to find your place. Canvas positions, colors, and view controls affect presentation rather than the relational meaning of the model.
Table colors use the same schema-aware algorithm as SQL to ERD. Missing colors are assigned automatically; existing manual colors and gradients are retained. Use Table Colors for Bright, Balanced, Deep or Clear, or choose a table’s own color. Sidebar indicators show the same colors as the canvas, including gradient previews. Theme changes keep your saved choices.
On desktop, drag the divider between tables and the canvas to resize them. Focus the divider and use Left/Right arrows, Shift for larger steps, or Home/End for its limits. Double-click restores the default width; Escape cancels a drag. Click the centered arrow to hide the tables panel and reopen it at its previous width, keeping your editor and search. A canvas pencil or column edit reopens it; ordinary selection does not. Panel sizing and visibility stay local to this workspace. On phones, switch between Diagram and Tables & details.
Create a named, colored group from Groups in the sidebar, then choose its tables. A table belongs to one group at a time; choosing tables from another group moves them into the edited group. Drag the group frame header to move its members together, or press Escape to cancel. Group changes and moves support Undo/Redo. Ungrouping keeps every table, column and relationship; groups are saved presentation metadata and never change exported SQL.
Use Undo and Redo to review design changes, including edits, duplication, comments, and indexes. Table and column action menus are anchored beside their trigger rather than at the bottom of the panel. Select an item before editing or deleting it, and check the affected relationships when removing a table or column.
Save your design and review its output
New designs remain in memory until you choose Save or File → Download JSON; there is no automatic local draft. Save signs in when needed and creates an independent DB Diagram cloud file. The first successful save gives the design its own URL. Save again after editing; the button shows Saving… while the request runs, and a success notification confirms completion.
File → Open diagrams opens the DB Diagram file list. Owners can edit and save their files. To share, save the latest changes, then choose File → Share diagram and enable public access. A public viewer sees the saved version read-only and can export it; the link does not grant editing permission.
Download JSON to keep the editable model, or import JSON exported by this tool. Portable imports support up to 128 MB and still enforce the model limits. Arbitrary SQL, another application’s JSON, and a Chen Builder file are not DB Diagram imports. Import validates the whole file before replacement; when the current design has tables, it asks for confirmation. Undo restores the previous design.
Export SQL to copy or download a script for the selected dialect. Open the generated SQL in the SQL workspace to inspect it alongside ERD, Data, and Query views. That handoff creates a separate SQL document.
Use image export to capture the diagram as PNG, SVG, or PDF. SVG contains an embedded PNG rather than editable vector shapes; PDF is a single page with an embedded image and non-selectable text. JSON retains the editable DB Diagram model and its canvas appearance and layout.
If saving fails, keep the workspace open, download JSON, and retry Save when ready. File → New diagram opens a fresh Blank/Template chooser. Unsaved changes warn before leaving, but a warning is not a backup; download or save the model before closing the page.
Keyboard shortcuts and model limits
| Action or limit | Behavior |
|---|---|
| Ctrl/Cmd+S | Save to cloud, including valid pending field edits; sign in when prompted. Saving is not triggered from an open dialog. |
| Ctrl/Cmd+Z / Ctrl/Cmd+Shift+Z / Ctrl+Y | Undo / Redo outside text fields and dialogs. Text fields retain their native editing shortcuts. |
| Delete / Backspace | Request deletion of the selected table, column or index outside text fields and dialogs; confirm the removal before it is applied. |
| Enter / Escape in a field | Commit a valid single-line edit / cancel the field draft and restore the previous value. |
| Escape outside fields and dialogs | Clear selection and close the expanded table editor. During a divider or group drag, cancel that preview. |
| Tables and columns | 200 tables, 200 columns per table, and 5,000 columns overall. |
| Relationships and indexes | 1,000 relationships and 5,000 column pairs; 50 named indexes per table and 1,000 per design. |
| Comments and cloud file name | 2,000 characters per table or column comment (1,024 for MySQL column comments); 3–259 characters for a cloud file name. Database identifiers have dialect-specific limits. |
| History | Up to 80 undo states in the current workspace. Undo history is not part of the saved file. |
Understand a design warning
| What you see | What to check |
|---|---|
| A table or column name is already used | Choose another name in that table or design. Case and quoting rules differ between databases; review exported identifiers. |
| A relationship cannot be added | Choose a complete primary or unique referenced key and matching types for every column pair. Check width, scale, unsigned and array modifiers. |
| An edit stays visible with an error | Read the message below the field, correct the value and commit again, or press Escape to restore the previous value. The rejected edit has not changed the model. |
| A connection disappeared after deletion | Deleting a table or column removes relationships that use it. Use Undo if the removal was unintended. |
| A shared design cannot be edited | Public files are read-only. The owner edits and saves the original. |
| Exported SQL needs adjustment | Check the selected dialect, types, defaults, key rules, and the target database version before running the script. |
Ask an assistant to review the model
Copy this guide as an AI prompt and describe your tables, columns, keys, relationship direction, and target dialect. Ask the assistant to explain ambiguous business rules before suggesting constraints.
Build the reviewed model with the visual controls. You can share generated SQL with an assistant for review, but importing arbitrary SQL or an invented DB Diagram JSON document is not supported.
Review a SQLite database design for customers and orders.
Each order belongs to one existing customer.
Explain the referencing and referenced columns.
Recommend primary keys, nullability, and useful uniqueness rules.
Do not assume that every customer must already have an order.