Database Schema Designer
Draw tables or write DBML, then get SQL for five databases, Prisma and a data dictionary.
Try before you buy.
- Free preview: the whole diagram and every check of your design, with the first lines of each export (up to 20).
- Locked until you unlock it: download and copy.
- Unlock: Pro pass, ₹179 for 30 days or ₹79 for 1 week, a one-time payment that never renews. Unlock: Pro pass, $5.99 for 30 days or $2.99 for 1 week, a one-time payment that never renews.
Ways to unlock shows how to get the full result.
Printing this result is locked in the free preview.
No table yet: add one with Table above, start from a template, or import SQL.
Columns
Indexes
An enum is a fixed list of values a column may take; give a column the enum’s name as its type.
PostgreSQL, MySQL or MariaDB, SQLite or SQL Server, as a schema dump writes it. Tables, keys, indexes, enums and comments are read; data and other statements are skipped. Importing replaces the design (Undo brings it back).
Tab moves from table to table. Arrow keys move the focused table (Shift for bigger steps) and Enter opens it in the editor. On the empty canvas, arrow keys pan; plus and minus zoom; 0 fits the design.
Checks and exports
Locked in the free preview. Opens the ways to unlock this result.
Locked in the free preview. Batch runs unlock with a pass.
Locked in the free preview. Query results unlock with a pass.
About the Database Schema Designer
Plan an app’s database before you write a migration. Add tables on the canvas, give each column a type, a default and its flags (primary key, not null, unique, counting up by itself), and link tables: many to one becomes a foreign key, one to one a unique foreign key, many to many a join table with a key to each side. Or write the design as DBML or a short shorthand and watch the diagram follow as you type, or import the CREATE TABLE statements of a database you already have (PostgreSQL, MySQL or MariaDB, SQLite, SQL Server).
The diagram uses crow’s-foot ends: a ring for “zero”, a bar for “one”, a fork for “many”, a solid line when the key is part of the child’s primary key. Checks run on every change: tables without a primary key, foreign keys without an index, keys whose type differs from what they point at, names that are reserved words in PostgreSQL, MySQL, SQL Server, SQLite or Oracle, names too long for a database, and naming that mixes styles.
The design exports as CREATE TABLE scripts for PostgreSQL, MySQL, SQLite, SQL Server and Oracle, a Prisma schema, DBML, the shorthand, a Mermaid erDiagram, JSON Schema, a data dictionary (Markdown, one HTML file or PDF) and the diagram as SVG or PNG. Everything runs in your browser, and the design is kept in this browser and in a file you save. Without a pass the diagram and the checks are complete and each export is a free preview of its first lines; downloading and copying the exports unlock with a Pro pass.
How to use it
- Start from a template (users and roles, shop orders, bookings, CRM, blog), a blank design, a file, or your own SQL under Import SQL.
- Add tables with Table, then pick a table (click it on the canvas or choose it under Table to edit) to name it and edit its columns, indexes and note.
- Under Relationships, choose the kind, the table that holds the key and the table it points to; leave “A new column” to have the key column made for you.
- Prefer typing? Switch to DBML or Shorthand: the diagram follows the text, and each problem is listed with its line.
- Read Checks, fix what they point at, then open Export and choose the format. With a pass, or once this design is unlocked, download or copy it; the free preview shows the first lines.
Examples
Ref: orders.customer_id > customers.id [delete: cascade]
ALTER TABLE orders ADD CONSTRAINT orders_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES customers (id) ON DELETE CASCADE;
> is many to one (orders holds the key), - one to one (the key is also unique), <> many to many (a join table orders_customers is made).
id bigserial [pk]
PostgreSQL BIGINT GENERATED BY DEFAULT AS IDENTITY · MySQL BIGINT AUTO_INCREMENT · SQLite INTEGER PRIMARY KEY AUTOINCREMENT · SQL Server BIGINT IDENTITY(1,1) · Oracle NUMBER(19) GENERATED BY DEFAULT AS IDENTITY
orders - id PK bigint AUTOINCREMENT customer_id bigint FK >- customers.id note text NULL # what the customer wrote
Table orders with a primary key, a foreign key to customers and a nullable note
What each SQL script contains
- PostgreSQL:
CREATE TYPE … AS ENUMfor enums, identity columns, named primary, unique and foreign keys,COMMENT ONfor notes. - MySQL: InnoDB tables in utf8mb4 (so foreign keys are enforced),
ENUM(…)columns,AUTO_INCREMENT,COMMENTclauses; MySQL has no time-zone timestamp, so timestamptz becomesDATETIME(store UTC). - SQLite: foreign keys inside
CREATE TABLE(SQLite cannot add one later) and a reminder that SQLite checks them only afterPRAGMA foreign_keys = ON; enums and booleans become text and integers with aCHECK. - SQL Server:
IDENTITY(1,1),NVARCHARfor text, named defaults, and notes asMS_Descriptionextended properties. - Oracle: identity columns,
VARCHAR2(n CHAR),NUMBERfor integers and booleans with aCHECK,COMMENT ONfor notes.
Every script creates the tables first and adds the foreign keys afterwards (except SQLite), so tables that point at each other work in any order. A name is quoted only where that dialect needs it: a reserved word, a space, or capitals in PostgreSQL. What a dialect cannot hold (an index on an expression or a cascade on a key to the same table in SQL Server, ON UPDATE in Oracle) is listed under the script, and MySQL gets the defaults of TEXT and JSON columns in the parentheses it requires.
Prisma schema
The Prisma export is a schema.prisma for Prisma ORM 7: the prisma-client generator with its output folder, and a datasource that names only the provider, because Prisma ORM 7 keeps the connection URL in prisma.config.ts (Prisma’s upgrade guide). Each table becomes a model with @@map to its name, each column a camelCase field with @map, keys become @id, @@id, @unique and @@index, defaults become autoincrement(), now(), uuid() or dbgenerated(), and every relation has its @relation(fields, references, onDelete) side and its list (or optional) side. Choose PostgreSQL, MySQL, SQLite or SQL Server for the provider: native types such as @db.VarChar(255) and @db.Uuid follow it, and what that database lacks in Prisma (Json fields and enums on SQL Server) is written as String and listed. Json fields and enums on SQLite are kept: Prisma supports both there and checks the enum values itself (Prisma schema reference).
DBML and the shorthand
The DBML reader follows the DBML documentation: Project, Table (schema names, as aliases, notes), column settings (pk, not null, unique, increment, default, note, inline ref), indexes and checks blocks, Ref in its short and long forms with delete and update actions, Enum, TableGroup and TablePartial. Sample records and sticky notes are skipped, and say so.
The shorthand is a compact text in the style of QuickDBD: a table’s name, a line of dashes, then one column per line as name type with PK, NULL, UNIQUE, INDEX, AUTOINCREMENT, DEFAULT value or FK >- table.column after it (- for one to one, >-< for many to many, -< when the other column holds the key). Columns are NOT NULL unless they say NULL, and text after # is a note.
Reserved words and name lengths
Names are checked against each vendor’s own list: the reserved key words of PostgreSQL, the reserved words of MySQL, SQL Server and Oracle, and the keywords of SQLite. A name such as order, user or desc then needs quotes in every query, so the check names a plain alternative. Lengths: PostgreSQL cuts a name longer than 63 bytes, MySQL allows 64 characters, SQL Server 128 characters and Oracle 128 bytes; the check counts characters, so names in other scripts than Latin reach the byte limits sooner.
Limitations
- A design describes tables, keys, indexes, enums and notes. Views, triggers, functions, partitions and permissions are not part of it, and the SQL import skips them (and counts them).
- Types are mapped between dialects for the common types (integers, decimals, text, dates and times, UUID, JSON, binary); any other type, such as a PostGIS geometry, is written as it is in every dialect and noted by the checks.
- Positions on the canvas are kept in this browser and in the saved file; DBML and SQL have no place for them, so a design read from text is arranged again.
- The shorthand is this tool’s own compact syntax in the style of QuickDBD, not a copy of any other tool’s grammar: check the rules above before you paste text from elsewhere.
Privacy
On this device: nothing is sent
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
What do I get without a pass?
Without a pass, Database Schema Designer shows the whole diagram and every check of your design, with the first lines of each export (up to 20). Until you unlock it, the result can’t be downloaded or copied. A Pro, Premium or Ultimate pass, a one-time payment that never renews, unlocks the full result. The pricing page lists the passes and their prices.
Which databases can it write SQL for?
PostgreSQL, MySQL (also MariaDB), SQLite, SQL Server and Oracle. Each script uses that database’s own types, identity columns and comment syntax, and lists anything that could not be carried over.
Can I start from my existing database?
Yes. Dump its schema (for example pg_dump --schema-only, mysqldump --no-data or sqlite3 app.db .schema), paste the result under Import SQL and press Import. The diagram is arranged by itself; move tables wherever you like. The SQL to ER Diagram tool reads the same SQL when you only need the picture.
Why does it warn about foreign keys without an index?
PostgreSQL, SQL Server, Oracle and SQLite do not index a foreign key by themselves, so deleting a parent row, or joining from the parent, reads the whole child table. MySQL’s InnoDB adds such an index when there is none. Adding the index the check names avoids slow deletes and joins.
How is many to many stored?
As a join table with a foreign key to each side and a primary key over both columns, which is how every relational database stores it. The designer makes that table for you (posts_tags for posts and tags) and you can add columns to it, such as when the link was made.
Is my design uploaded?
No. Drawing, checking and every export happen in your browser. The design is kept in this browser’s storage so it is there when you come back, and Save file writes it to a file you keep.