JoyToolsJoyTools

Database ER Diagram Builder

100% Client-Side Private — Zero Server Uploads

Design database schemas visually with drag-and-drop or DBML code. Export PostgreSQL, MySQL, and SQLite DDL scripts and download PNG/SVG diagrams. No account needed.

🔒 100% Client-Side: All data is processed locally in your browser and never leaves your device (Zero Server Uploads).
E-E-A-T Security Proof →
Interactive Workspace

Tables (2)

Relations (1)

posts.user_id → users.id
PKColumn NameTypeNULL
Share & Developer Embed

How do I use Database ER Diagram Builder?

1

Write or paste DBML / SQL schema definitions in the editor, or click "Load Sample Data".

2

Inspect and rearrange the interactive Entity-Relationship Diagram (ERD) nodes on the canvas.

3

Export the schema to PostgreSQL, MySQL, SQLite DDL, or download the ERD diagram.

What features does Database ER Diagram Builder offer?

Design tables with 23 column types — INTEGER, VARCHAR, UUID, JSONB, TIMESTAMPTZ — and export CREATE TABLE scripts instantly

SQL DDL export for PostgreSQL, MySQL/MariaDB, and SQLite

Foreign key relationships with CASCADE, SET NULL, RESTRICT rules

Primary key, NOT NULL, UNIQUE constraints per column

No account, no signup, no cloud storage — runs entirely in your browser

Relational Cardinality & Foreign Key Referential Actions

Maps DBML relationship operators to ANSI SQL Foreign Key constraints and Crow's Foot notation.

DBML Relationship Syntax vs SQL DDL Foreign Key Semantics
DBML OperatorCardinality TypeSQL DDL ImplementationReferential Integrity Rule
Ref: A.id < B.a_idOne-to-Many (1:N)FOREIGN KEY (a_id) REFERENCES A(id)Index required on B.a_id to avoid table locks
Ref: A.id > B.a_idMany-to-One (N:1)FOREIGN KEY (id) REFERENCES B(a_id)Child row cannot exist without parent row
Ref: A.id - B.a_idOne-to-One (1:1)FOREIGN KEY (a_id) REFERENCES A(id) UNIQUEEnforces unique constraint on foreign key column
Ref: A.id <> B.idMany-to-Many (M:N)Junction Table A_B (a_id, b_id, PRIMARY KEY(a_id, b_id))Resolved via composite primary key join table

Frequently Asked Questions about Database ER Diagram Builder

How are Many-to-Many (`M:N`) relationships resolved when exporting to SQL DDL?

Relational databases cannot enforce direct `M:N` foreign keys between two tables. Always model an explicit junction (associative) table with two `1:N` foreign keys and a composite primary key (`PRIMARY KEY (user_id, role_id)`).

Why should Foreign Key columns always be indexed in PostgreSQL?

PostgreSQL automatically creates a B-Tree index for `PRIMARY KEY` and `UNIQUE` constraints, but NOT for `FOREIGN KEY` columns. Without an index on the child column, `DELETE` or `UPDATE` on the parent table triggers a full sequential scan lock.

Are database diagrams stored in the cloud or transmitted externally?

No, your database schema and ERD layout are parsed and rendered 100% locally in your browser using HTML5 Canvas/SVG and persisted only in local browser storage if desired.

What is the difference between `ON DELETE CASCADE` and `ON DELETE RESTRICT`?

`CASCADE` automatically deletes all dependent child rows when a parent row is deleted, whereas `RESTRICT` (or `NO ACTION`) aborts the transaction with a foreign key violation error if any child records exist.