Schema Designer for Your First Tables

Schema Designer: Create database tables and generate SQL
← Back to Home

A schema is the plan of your database: which tables exist, which columns they have and what kind of data each column holds. The designer above lets you sketch tables and turns them into CREATE TABLE statements. It runs in your browser and saves nothing on our server.

How to use the designer

  1. Click Add Table and give the table a name, such as students.
  2. Add columns. For each one, choose a name and a type.
  3. Mark one column as the primary key, usually id.
  4. Click Generate SQL, read the statement, then Copy to Clipboard.
  5. Paste it into your database tool, such as DB Browser for SQLite or psql, and run it on a practice database.

Choosing column types

A type tells the database what kind of value a column holds. Picking the right one prevents silly mistakes, like storing "twelve" in an age column.

If the column holds...A sensible type
Whole numbers, such as a quantityINTEGER
Money amountsDECIMAL (or store whole cents as INTEGER)
Short text, such as a nameVARCHAR or TEXT
Yes or noBOOLEAN
A dateDATE
A date and timeTIMESTAMP

Type names vary a little between databases. SQLite, for example, is relaxed about types unless you use its stricter table options. Our guide to SQL data types for beginners explains the differences.

Three rules worth adding

A tiny example

CREATE TABLE students (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT UNIQUE,
  enrolled_on DATE
);

Read it aloud: "A students table. Each student has an id that identifies them, a name they must have, an email no one else can share, and the date they enrolled."

Linking tables

If you add a second table, such as enrolments, give it a column like student_id that refers to students.id. That is a foreign key. The designer generates the tables; you can add the foreign key line yourself, as shown in how to add a foreign key between two tables.

Before you build for real

When your projects grow and speed starts to matter, the sister site databaseintegrate.com covers indexes and performance for working developers.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.