Test a primary key constraint
Easy30 pts~12 min
- Primary keys
- Generated ids
Practice app · Acme Commerce DB
A real SQL database (SQLite engine) seeded with an e-commerce and HR dataset, with schema browser and query runner.
Your starter code already declares TEST_URL — never hardcode a host.
Objective
Verify departments.id rejects a duplicate key and assigns the next id when omitted.
Your task
- 1Insert department (id 2, name 'Platform', location 'Austin'); id 2 already exists, so it must fail.
- 2Insert name 'Platform', location 'Austin' again without an id; it must succeed with id 7.
- 3Verify: SELECT id, name, location FROM departments.
Acceptance criteria
- The duplicate id fails with UNIQUE constraint failed: departments.id
- The last result set shows 7 departments including Platform
Constraints
- Every run starts from a freshly seeded database, so your script must include its own setup statements.
- A failing statement is recorded and the script keeps running, so you can trigger an error and verify afterwards.
- Only the last result set of your script is compared, so finish with the verification query.
SQL (SQLite engine) · Database Testing · Constraints & keys