Home › Developer Tools › Database Schema Designer

Database Schema Designer

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:

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

  1. 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.
  2. Define the columns: name, data type, size, default value and the PK, Not null, Unique and Auto inc. flags. Reorder with the arrows.
  3. 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.
  4. Arrange the diagram by dragging tables, or press Arrange tables for an automatic layout. Zoom with Fit, + and −.
  5. 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 typeMySQL 8PostgreSQLSQLite
INT / BIGINT / SMALLINTINT / BIGINT / SMALLINTINTEGER / BIGINT / SMALLINTINTEGER
DECIMAL(p,s)DECIMAL(p,s)NUMERIC(p,s)NUMERIC
FLOAT / DOUBLEDOUBLEDOUBLE PRECISIONREAL
BOOLEANBOOLEAN (TINYINT(1))BOOLEANINTEGER (0/1)
VARCHAR(n) / CHAR(n) / TEXTVARCHAR(n) / CHAR(n) / TEXTVARCHAR(n) / CHAR(n) / TEXTTEXT
DATE / TIME / DATETIMEDATE / TIME / DATETIMEDATE / TIME / TIMESTAMPTEXT (ISO 8601)
TIMESTAMP (with time zone)TIMESTAMPTIMESTAMPTZTEXT
UUIDCHAR(36)UUIDTEXT
JSONJSONJSONBTEXT
BLOBBLOBBYTEABLOB

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.

Related tools

SQL to ER DiagramPaste CREATE TABLE statements and get an entity-relationship diagram with keys and links.SQL Create Table GeneratorDefine columns, keys, defaults and indexes; get CREATE TABLE SQL for MySQL, Postgres and more.SQL Query BuilderBuild SELECT queries visually: joins, filters, GROUP BY, ORDER BY and LIMIT, as clean SQL.SQLite ViewerOpen .db and .sqlite files in your browser, browse tables and run SQL queries.SQL Dialect ConverterTranslate SQL between MySQL, PostgreSQL, SQLite, SQL Server, Oracle, BigQuery and more.QR Code GeneratorMake QR codes for links, Wi-Fi, email and more.Barcode GeneratorCreate Code 128, EAN-13, UPC-A, EAN-8, Code 39 and ITF-14 barcodes as PNG or SVG.UUID GeneratorGenerate UUID v4 and v7 / GUIDs in bulk and copy or download them.Schema Markup Generator (JSON-LD)Create JSON-LD structured data for FAQ, Product, Article and more.Htaccess & Nginx Redirect GeneratorBuild 301 redirects for .htaccess, Nginx and Netlify or Cloudflare _redirects.Fake Data GeneratorGenerate mock data as JSON, CSV or SQL.Random String GeneratorGenerate secure random strings and tokens in bulk with any length and character set.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.MIME Type LookupFind the MIME type for any file extension, or the extensions for a MIME type, in 400+ entries.Cron Expression GeneratorBuild crontab schedules visually, read them in plain English and see the next run times.URL Slug GeneratorTurn titles into clean, SEO-friendly URL slugs: accents, stop words, separators and bulk lines.JSON Schema GeneratorTurn sample JSON into a draft 2020-12 JSON Schema with types, required fields and formats.Gitignore GeneratorBuild a .gitignore from 50+ templates for languages, frameworks, IDEs and OS, merged and deduped.License GeneratorCreate a LICENSE file for MIT, Apache, GPL, BSD, ISC, MPL or Unlicense with your name and year.ULID GeneratorGenerate sortable ULIDs and UUID v7 in bulk, monotonic option, and decode their timestamps.Htpasswd GeneratorCreate .htpasswd entries with bcrypt, APR1-MD5 or SHA-1 for Apache and Nginx basic auth.Placeholder Image GeneratorCreate placeholder images in any size, color and text as PNG, JPG, WebP, SVG or data URI.Ads.txt GeneratorCreate or validate ads.txt and app-ads.txt files: seller lines, cert IDs and variables.Docker Run to Compose ConverterConvert docker run commands to docker-compose.yml, or a compose file back to docker run.Dockerfile GeneratorGenerate a production Dockerfile and .dockerignore for Node, Python, Go or a static nginx site.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.JSON to Zod SchemaInfer a Zod (or Yup) schema from sample JSON with optional, nullable and z.infer types.Linux Commands Cheat SheetSearchable Linux and bash command reference with flags explained, examples and copy buttons.LLMs.txt GeneratorBuild an llms.txt file for AI crawlers: summary and link sections, import from your sitemap.Nano ID GeneratorGenerate secure Nano IDs with custom alphabet, length and count, plus a collision calculator.Nginx Config GeneratorBuild an nginx server block: static site, SPA, reverse proxy or PHP, with SSL, gzip and redirects.OpenAPI / Swagger ViewerView OpenAPI 2/3 JSON or YAML as interactive API docs with validation and an endpoint list.package.json GeneratorFill a form and get a valid, npm-ready package.json with scripts, dependencies and checks.PKCE Code Challenge GeneratorGenerate an OAuth 2.0 PKCE code_verifier and S256 code_challenge, build auth URLs, verify pairs.README GeneratorFill in a form and get a polished README.md with badges, install, usage and license, live preview.Regex GeneratorBuild regular expressions visually from blocks or presets (email, date, phone) and test them live.Commit Message GeneratorBuild Conventional Commit messages with type, scope, body, breaking change and issue refs.Docker Compose GeneratorBuild a docker-compose.yml with a form: services, ports, volumes, env, healthchecks and presets.tsconfig.json GeneratorBuild a tsconfig.json with target, module, strict checks and path aliases, each option explained.Access Log AnalyzerAnalyze Apache and Nginx access logs: top URLs, IPs, status codes, bots and traffic charts.Regex String GeneratorGenerate random test strings that match any regular expression, checked against the real regex.ASCII Table GeneratorTurn CSV or pasted cells into plain-text tables: MySQL, Markdown, Unicode box and reST styles.Dummy File GeneratorCreate test files of an exact size in KB, MB or GB with zeros, random bytes or text.FFmpeg Command GeneratorPick a task and options, get the exact ffmpeg command with every flag explained.Folder Tree GeneratorTurn a local folder or an indented list into an ASCII directory tree for your README.GitHub Actions Workflow GeneratorBuild a GitHub Actions CI workflow: triggers, matrix, caching, tests, Pages or Docker deploy.Kubernetes YAML GeneratorGenerate Deployment, Service, Ingress, ConfigMap, Secret and HPA manifests with safe defaults.Markdown TOC GeneratorGenerate a linked table of contents from Markdown headings with GitHub-style anchors.OpenAPI EditorEdit OpenAPI/Swagger YAML or JSON side by side with live API docs, validation and download.OpenAPI ValidatorValidate OpenAPI 3.0/3.1 and Swagger 2.0 specs: schema errors, broken $refs, line numbers.Pivot Table MakerBuild pivot tables from CSV or Excel by drag and drop: sum, count, average, charts, export.Truth Table GeneratorType a logic expression and get its full truth table, minterms and canonical DNF/CNF.TypeScript PlaygroundWrite TypeScript with live type checking, see the compiled JavaScript and run it in your browser.Article Schema GeneratorCreate Article, BlogPosting or NewsArticle JSON-LD with headline, authors, dates and images.Event Schema GeneratorCreate Event JSON-LD with dates, venue or online location, tickets, organizer and performers.Google Search Query BuilderBuild advanced Google searches with site:, filetype:, intitle:, exact phrases and date operators.HowTo Schema GeneratorCreate HowTo JSON-LD with steps, tools, supplies, total time and cost, then copy it.Htaccess GeneratorBuild an Apache .htaccess file: HTTPS, www, gzip, caching, error pages, IP blocks, hotlinks.HTML Email Template BuilderDrag and drop blocks to build a responsive, table-based HTML email with inline styles.Organization Schema GeneratorCreate Organization JSON-LD with logo, URL, contact points, address and social profiles.PIN GeneratorGenerate random 4, 6 or 8-digit PINs that avoid sequences, repeats, dates and common PINs.Product Schema GeneratorBuild Product JSON-LD with price, availability, brand, GTIN, ratings and reviews.Question Keyword GeneratorFind the questions people ask about a topic, grouped by who, what, why, how, can and more.Recipe Schema GeneratorCreate Recipe JSON-LD with ingredients, steps, prep and cook times, nutrition and ratings.Security Headers GeneratorPick HSTS, CSP, frame, referrer and permissions options and get Apache, Nginx, Netlify or Cloudflare config.SKU GeneratorBuild consistent SKUs from brand, category, size and color, then export every variant as CSV.Typography Scale GeneratorBuild a modular type scale from a base size and ratio, then copy CSS variables or a Tailwind config.WordPress Salt GeneratorGenerate fresh WordPress security keys and salts for wp-config.php, .env or Docker in one click.
See all 85 Code Generators & Builders →