Database Viewer

Browse the SQL that builds any database used across the lessons, without running it.

Loaded: Introduction to JOIN database ยท introduction-to-join.database-init

CREATE TABLE "User" (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT NOT NULL
);

CREATE TABLE "Order" (
  id SERIAL PRIMARY KEY,
  user_id INTEGER NOT NULL REFERENCES "User" (id),
  amount NUMERIC NOT NULL
);


INSERT INTO "User" (name, email)
VALUES
  ('Ada Lovelace', 'ada@example.com'),
  ('Grace Hopper', 'grace@example.com');

INSERT INTO "Order" (user_id, amount)
VALUES
  (1, 42.00),
  (1, 15.50),
  (2, 9.99);

ANALYZE "User";
ANALYZE "Order";