Design your database visually: add tables, define columns, data types, primary keys and foreign keys, and watch the entity-relationship diagram update as you go. The matching CREATE TABLE script for MySQL, PostgreSQL or SQLite is generated live, and you can save the design as JSON to keep working on it later.
Last updated:
No tables yet. Press Add table to start.
Drag tables to move them · drag empty space to pan · Ctrl + scroll to zoom · click a table to edit it
Import from SQL (CREATE TABLE statements)
SQL DDL
Advertisement
Advertisement
How to use the Database Schema Designer
Start from the example or press Add table. Click any table in the diagram (or choose it in the Edit table list) to open it in the editor.
Define the columns: name, data type, size, default value and the PK, Not null, Unique and Auto inc. flags. Reorder with the arrows.
Link tables by choosing a target in a column's References list; the line appears and the column type is matched to the key it points to.
Arrange the diagram by dragging tables, or press Arrange tables for an automatic layout. Zoom with Fit, + and −.
Pick a dialect (MySQL, PostgreSQL or SQLite), then copy or download the SQL. Use Save JSON to keep an editable copy of the design.
Type mapping by database
Design once with portable types; each export uses the closest native type of the target database.
Designer type
MySQL 8
PostgreSQL
SQLite
INT / BIGINT / SMALLINT
INT / BIGINT / SMALLINT
INTEGER / BIGINT / SMALLINT
INTEGER
DECIMAL(p,s)
DECIMAL(p,s)
NUMERIC(p,s)
NUMERIC
FLOAT / DOUBLE
DOUBLE
DOUBLE PRECISION
REAL
BOOLEAN
BOOLEAN (TINYINT(1))
BOOLEAN
INTEGER (0/1)
VARCHAR(n) / CHAR(n) / TEXT
VARCHAR(n) / CHAR(n) / TEXT
VARCHAR(n) / CHAR(n) / TEXT
TEXT
DATE / TIME / DATETIME
DATE / TIME / DATETIME
DATE / TIME / TIMESTAMP
TEXT (ISO 8601)
TIMESTAMP (with time zone)
TIMESTAMP
TIMESTAMPTZ
TEXT
UUID
CHAR(36)
UUID
TEXT
JSON
JSON
JSONB
TEXT
BLOB
BLOB
BYTEA
BLOB
Schema design checklist
Give every table a primary key. A surrogate id BIGINT with auto increment is the simplest choice; natural keys such as an email address tend to change.
Model many-to-many links with a junction table (like project_members in the example) whose primary key is the pair of foreign keys.
Match foreign key types exactly. A BIGINT key referenced by an INT column fails in MySQL and wastes space elsewhere; the designer warns about mismatches.
Choose ON DELETE deliberately: CASCADE for child rows that make no sense alone (comments of a task), SET NULL for optional links (a task's assignee), and the default (no action) where deletes should be blocked.
Normalize first, denormalize later. Store each fact once (third normal form) and only duplicate data when a measured query needs it.
Use NOT NULL by default and allow NULL only when "unknown" is a real state. It simplifies queries and lets the diagram show mandatory links with solid lines.
Name consistently: lowercase snake_case, plural table names and <table>_id foreign keys avoid quoting and make joins obvious.
Frequently asked questions
What does the schema designer export?
A ready-to-run SQL script of CREATE TABLE statements with primary keys, NOT NULL, UNIQUE, defaults and named foreign key constraints, plus optional DROP TABLE and CREATE INDEX statements. It can also save the design as JSON (to reopen here later) and the diagram as a PNG image.
How are data types translated between MySQL, PostgreSQL and SQLite?
You design with portable types and each dialect gets its native equivalent. For example, TIMESTAMP with time zone becomes TIMESTAMP in MySQL, TIMESTAMPTZ in PostgreSQL and TEXT in SQLite; UUID becomes CHAR(36), UUID and TEXT; JSON becomes JSON, JSONB and TEXT. SQLite uses only its storage classes (INTEGER, REAL, TEXT, BLOB, NUMERIC).
How is auto increment written for each database?
MySQL uses AUTO_INCREMENT, PostgreSQL uses GENERATED BY DEFAULT AS IDENTITY (the SQL-standard replacement for SERIAL), and SQLite uses INTEGER PRIMARY KEY AUTOINCREMENT, which is only allowed on a single-column integer primary key.
In what order are the tables created?
Referenced tables are created before the tables that point to them, so the script runs top to bottom without errors. If two tables reference each other, the second foreign key is added afterwards with ALTER TABLE in MySQL and PostgreSQL. SQLite accepts forward references, so all keys stay inline.
Why index foreign key columns?
Joins and ON DELETE checks look up rows by the foreign key column. MySQL's InnoDB creates that index automatically, but PostgreSQL and SQLite do not, so the tool adds CREATE INDEX statements for those dialects unless you turn the option off.
Where is my schema stored?
Only in your browser. The design is auto-saved to local storage on this device, and Save JSON downloads a file you can back up, share or open later with Open JSON. Nothing is sent to a server.
Can I edit an existing database?
Yes. Export its schema as SQL (for example mysqldump --no-data or pg_dump --schema-only), paste it into Import from SQL, and the tables, keys and relationships appear in the designer ready to change.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.