Question & tables Load the workspace to begin.
30:00
Start / resume mock Question Finish and review Database schema customers(id, name, country)
orders(id, customer_id, ordered_at, amount, status)
employees(id, name, department, salary, manager_id)
events(id, user_id, event_date, event_type)
products(id, name, category, price, stock) orders.customer_id → customers.id employees.manager_id → employees.id events.user_id is a separate product-user identifier.
All data is synthetic. Dates use YYYY-MM-DD; unknown values are NULL.
Schema design, changes & performance Use PRIMARY KEY for identity, FOREIGN KEY for relationships and NOT NULL for required values. Normalise repeated entities into related tables. In this sandbox, foreign keys are enabled.
BEGIN;
CREATE TABLE audit_notes(id INTEGER PRIMARY KEY, note TEXT NOT NULL);
INSERT INTO audit_notes VALUES(1, 'First note');
SELECT * FROM audit_notes;
ROLLBACK;BEGIN groups changes; COMMIT keeps them within a run and ROLLBACK undoes them. Each new run resets the whole sandbox. Try EXPLAIN QUERY PLAN before and after CREATE INDEX. Tiny sample data cannot predict production performance.
Your SQL query Ctrl / Cmd + Enter to run Run query Check answer Stop Reset query Save draft Download SQL
Loading the SQL engine…
Queries run locally, with an eight-second execution limit and a 500-row result limit. Signed-in learners can save exercise queries to their academy account. Practice results never change course grades or certificates.
This workspace needs JavaScript and WebAssembly. You can still read the question and reference solution.