Database ER Diagram Builder
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.
Tables (2)
Relations (1)
How do I use Database ER Diagram Builder?
Write or paste DBML / SQL schema definitions in the editor, or click "Load Sample Data".
Inspect and rearrange the interactive Entity-Relationship Diagram (ERD) nodes on the canvas.
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 Operator | Cardinality Type | SQL DDL Implementation | Referential Integrity Rule |
|---|---|---|---|
| Ref: A.id < B.a_id | One-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_id | Many-to-One (N:1) | FOREIGN KEY (id) REFERENCES B(a_id) | Child row cannot exist without parent row |
| Ref: A.id - B.a_id | One-to-One (1:1) | FOREIGN KEY (a_id) REFERENCES A(id) UNIQUE | Enforces unique constraint on foreign key column |
| Ref: A.id <> B.id | Many-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.
Explore Related Developer Tools
JSON to SQL DDL & INSERT Statement Generator
Convert JSON objects or arrays into CREATE TABLE DDL schemas and INSERT INTO SQL statements for PostgreSQL, MySQL, SQLite, and SQL Server.
Mock Data Generator
Generate realistic fake data for testing: JSON, CSV, SQL, XML with 50+ field types — names, emails, UUIDs, dates, addresses. Runs 100% in your browser via Web Worker.
REST API Tester
Send HTTP requests (GET, POST, PUT, DELETE) directly from your browser. View response body, headers, status codes, and timing. Export as cURL or Python. No install required.
CSV to JSON Converter
Convert CSV spreadsheets and delimited text into structured JSON arrays with auto-delimiter and dynamic data type detection.
JSON to CSV Converter
Convert JSON object arrays into RFC 4180 compliant CSV spreadsheets ready for Excel, Google Sheets, and SQL imports.
Smart String Escaper & Unescaper (JSON, HTML, JS, SQL, Unicode)
Bidirectional escaping and unescaping tool for JSON, HTML Entities, JavaScript, SQL strings, and Unicode characters.