Database Viewer

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

Loaded: Types of JOINs database ยท joins.database-init

CREATE TABLE authors (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE books (
  id SERIAL PRIMARY KEY,
  title TEXT NOT NULL,
  author_id INTEGER REFERENCES authors (id)
);


INSERT INTO authors (name)
VALUES ('J.R.R. Tolkien'), ('Isaac Asimov'), ('Agatha Christie');

INSERT INTO books (title, author_id)
VALUES
  ('The Fellowship of the Ring', 1),
  ('The Two Towers', 1),
  ('I, Robot', 2),
  ('Beowulf', NULL);