Tools / Database Schema Designer

Database Schema Designer

Describe tables in plain text. Get CREATE TABLE SQL for PostgreSQL, MySQL or SQLite, a relationship diagram and a data dictionary. Runs in your browser. Nothing is uploaded.

Describe your tables

Dialect Primary key
On parent delete

Copy, download and the diagram are made on your device when you press a button. Nothing is sent anywhere. Generated SQL is a starting point: read it and test it on your database version before you run it on real data.

What is inside

What is inside the tool.

Plain-text input

A line with no colon starts a table. Fields are name:type with optional words: required, unique, index, default=VALUE and an arrow ->table for a foreign key. Comments start with #.

Three dialects

PostgreSQL, MySQL and SQLite. Types, auto-increment, UUID defaults, booleans, timestamps and identifier quoting change with the dialect. Reserved words such as order and user are quoted for you, with a warning.

Foreign keys

A field named customer_id points at the customer table when it exists. An arrow, ->customer or ->customer.code, sets it directly. The column takes the type of the key it points at. A foreign key to a column that is not unique is flagged.

Order and loops

Tables are written so that referenced tables come first. If two tables refer to each other, the loop is reported and the foreign key is added with ALTER TABLE afterwards (SQLite accepts it inside CREATE TABLE).

Primary keys and options

An id primary key on every table: auto-increment integer or UUID. Optional created_at and updated_at, optional index on foreign key columns, and a delete rule: cascade, set null or restrict.

Relationship diagram

Boxes for tables, a line for each foreign key, drawn as SVG you can download. Self-references and loops are drawn.

Data dictionary

A Markdown document with every column, type, rules, default and reference, plus which tables point at each table.

Line-numbered problems

Unknown types, unreadable lines, duplicate tables or fields, bad defaults, references to tables that do not exist, and similar problems are listed with the line number. Nothing is silently dropped.

Worked example

The sample on the tool page.

Click Sample. It describes a small shop with four tables: customer, product, order and order_line.

SettingResult
PostgreSQL, integer idsIds are INTEGER GENERATED ALWAYS AS IDENTITY, TIMESTAMPTZ for timestamps, and "order" is quoted because it is a reserved word.
MySQLIds are INT AUTO_INCREMENT, timestamps are DATETIME, `order` is quoted with backticks, and no extra foreign key indexes are written because InnoDB indexes them.
SQLiteIds are INTEGER PRIMARY KEY AUTOINCREMENT. The output ran in SQLite with foreign keys switched on, and an order for a customer that does not exist was refused.
UUID idsIds become UUID with gen_random_uuid() in PostgreSQL, CHAR(36) with UUID() in MySQL, and plain TEXT in SQLite, which has no default. Foreign key columns follow.
Delete rule: cascadeEvery foreign key gets ON DELETE CASCADE. Set null on a required column triggers a warning.

Reading the result

What each part on the tool page tells you.

The summary line

Tables, columns and foreign keys it found. If a foreign key you expected is missing, the name did not match a table or the arrow was misspelled. See the list under it.

The warnings

Each says which line and what it did instead, for example "unknown type, used text". When any part differs from what you wrote, a yellow box under the SQL lists each one and says to resolve them before you run it, and the SQL starts with a comment saying so.

The diagram

A line runs from the foreign key column to the id it points at. The filled dot is at the table being pointed at.

The dictionary

Use it as documentation. Required, unique and indexed show in the Rules column.

How to use it

Five steps.

Step 1

Type or paste your tables, or click Sample and edit it.

Step 2

Pick the dialect and the primary key style.

Step 3

Read the warnings. Fix the lines they name.

Step 4

Check the SQL tab and the diagram. Switch dialects to compare.

Step 5

Copy or download the SQL, the SVG or the Markdown. Test the SQL on your database version before using real data.

Common mistakes

Things that make a schema fail or behave oddly.

A foreign key to a column that is not unique

The database rejects it. The tool does not write that foreign key. It tells you and leaves the column plain until you mark the target column unique.

Required column with delete rule set null

Deleting the parent would have to write null into a column that cannot be null. The tool writes that foreign key without a delete rule and says so.

Index or unique rule on TEXT in MySQL

MySQL needs a length to index TEXT and JSON. The rule is left out with a note. Use string(n).

Defaults that do not fit the type

default=abc on an int, or a number on a bool. They are skipped with a warning instead of producing SQL that fails.

Index names that collide

Index names are unique across a schema, and a_b with column c and a with column b_c both want idx_a_b_c. The tool numbers the second.

Reserved words as names

order, user, group and key need quoting. The tool quotes them and warns.

Names too long for the database

PostgreSQL allows 63 characters in an identifier and MySQL 64. The tool refuses to produce SQL, lists the names, and the Copy and Download buttons stay off until you shorten them.

Design notes

Facts from the PostgreSQL manual that shape the output.

Foreign keys and indexes

The PostgreSQL manual says declaring a foreign key does not automatically create an index on the referencing columns, and that it is often a good idea to index them. That is why the tool has an option to index foreign key columns, on by default. MySQL InnoDB is handled differently, so it writes none.

What a foreign key can point at

The PostgreSQL manual says a foreign key must reference a primary key or a unique constraint. The tool warns when ->table.column points at a column that is not marked unique.

Identity columns

The PostgreSQL manual describes GENERATED ... AS IDENTITY columns. The tool uses GENERATED ALWAYS AS IDENTITY for PostgreSQL integer ids.

What it cannot do

Limits.

One column keys only

Every table gets a single id primary key. There are no composite primary keys, composite unique constraints or composite foreign keys.

No many-to-many shortcut

Write the join table yourself, like order_line in the sample.

No CHECK constraints, enums or partial indexes

Add them to the SQL by hand.

Updated-at triggers

updated_at gets a default only. Refreshing it on update needs a trigger, which the tool does not write.

Not a migration tool

It writes CREATE statements for a new schema. It does not read an existing database or write ALTER scripts to change one.

Versions

The output for the sample and the edge cases was run on MySQL 8.4.3, SQLite and PostgreSQL (PGlite 0.6.1, PostgreSQL compiled to WebAssembly). Your version may differ. For example gen_random_uuid() needs PostgreSQL 13 or the pgcrypto extension, and DEFAULT (UUID()) needs MySQL 8.0.13 or later.

What it does

What Database Schema Designer does.

Free database schema designer: describe tables in plain text, get PostgreSQL, MySQL or SQLite CREATE TABLE SQL, foreign keys, indexes, an ER diagram and a data dictionary. It runs in your browser.

FunctionWhat it does
InputShort line syntax, with a type list that maps to each SQL dialect
Choose SQL dialect and primary key styleYes, PostgreSQL, MySQL, SQLite, integer or UUID

Questions

Before you ask.

Is my schema uploaded?

No. Parsing, generating and drawing run in your browser tab.

Why is a foreign key missing?

The field name must be the table name plus _id, such as customer_id, or use ->customer. The table must exist in your text.

Why is my table name in quotes?

It is a reserved word in at least one dialect, such as order, user or group. Quoting keeps the SQL valid. A different name avoids the problem.

Why does my field named id disappear?

Every table already has an id primary key, so the extra one is skipped with a warning.

Can I run the SQL as is?

Read it first and try it on a test database of your version.

What does it cost?

Nothing. No account.

Your data

What stays on your device.

The tool runs in this browser tab and does not need a server. Your table descriptions stay in the page. The .sql file, the SVG diagram and the Markdown dictionary are made on your device only when you press their buttons. Nothing is uploaded or shared.

Try it

Sketch the schema and read the SQL it makes.

Open Database Schema Designer
A laptop, headphones, a camera, a phone and a plant on a white desk, seen from above, banner image on the Database Schema Designer page

Try it now.

Database Schema Designer runs in your browser. No account needed.

Database Schema Designer

See it at work

Free database schema designer: describe tables in plain text, get PostgreSQL, MySQL or SQLite CREATE TABLE SQL, foreign keys, indexes, an ER diagram and a data

Database Schema Designer
Fields
API
CLI
schema
dialect
primary_key
timestamps
index_foreign_keys
hiringsai tool database-schema-designer
schema string
dialect pg
primary_key int
timestamps False
6 fields, 1 required
curl -X POST https://hiringsai.com/api/v1/tools/database-schema-designer/run
-d '{"input": {"schema": "<text>"}}'
JSON result
hiringsai run database-schema-designer --input '{"schema": "<text>"}'
also callable over MCP
JSON result printed
Free toolAPI and MCPNo account
Fields
schemastring
dialectpg
primary_keyint
timestampsFalse
Ways to use it
pagethis app
APIPOST .../run
CLIhiringsai run
MCPtools/call
API call
POST /api/v1/tools/database-schema-designer/run
input: {"schema": "<text>"}
JSON result back
Command line
hiringsai run database-schema-designer
--input <json>
JSON result printed
The Database Schema Designer page as it opens
Database Schema Designer6 fields
The page as it opens, captured from the live site.
The Database Schema Designer app at phone width
Database Schema Designerphone layout
The same app at phone width.
A laptop on a wooden desk with a person typing
Database Schema DesignerFree tool
Free database schema designer: describe tables in plain text, get PostgreSQL, MySQL or SQLite CREATE TABLE SQL, foreign keys, indexes, an ER diagram and a data
A laptop glowing in a dark room
Database Schema DesignerAPI and MCP
Call it from a script over the API or MCP.