Schema Design Checkpoint

Design GreenMart's First Schema

Playground Checkpoint

Design and build a real schema — no auto-grading, just a real attempt.

15–20 min

The Challenge

Everything decided across this Act is spec now: three entities, primary keys, a foreign key link, four constraints, the right data type for every column, and a diagram showing how it all connects. Sarah did the thinking. Building it for real is next — and this time, it's on you.

Open the Playground and write the actual SQL that creates GreenMart's first real schema: three tables — Customers, Products, Sales — built exactly the way the last eight chapters worked it out.

What Your Schema Needs

  • A Customers table with a primary key (Customer ID), and NOT NULL on any field that should never be left blank.
  • A Products table with a primary key (Product ID), a UNIQUE constraint on the product name, and a CHECK constraint so Price can never be negative.
  • A Sales table with its own primary key (Sale ID), plus two foreign keys — one referencing Customers, one referencing Products.
  • The right data type for every column: numbers for Price and Quantity, text for names and phone numbers, a real date type for the sale date.
  • A DEFAULT of 0 on the Customers table's balance column, so a brand-new customer never starts out with a blank value.
Stuck? A Few Hints
  • Build Customers and Products first — Sales can't reference something that doesn't exist yet.
  • A foreign key needs the exact same data type as the primary key it points to.
  • Stuck on which columns a table needs? Chapters 3 through 7 already show every column GreenMart uses, one at a time.

Ready to Build It?

Opens the Playground, right in your browser — nothing to install.

Open Playground

Once your CREATE TABLE statements run with no error, this checkpoint is done. If you then run a SELECT against one of your new tables, seeing "Ran successfully — no rows returned" is exactly right — this challenge is about designing the schema, not inserting data yet.

Before You Move On

This exact SQL — CREATE TABLE, PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE, CHECK, DEFAULT — is Act 2's actual subject, chapter by chapter. If writing it here felt unfamiliar, that's expected: this checkpoint was about the design decisions Act 1 taught, not memorized syntax. The next Act is where the exact keywords get taught properly.

Next