SQL (SQLite engine)

Validate NOT NULL handling

Medium70 pts~25 min
  • NOT NULL
  • Negative testing
  • Nullable columns
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.

Test URL
/lab/database-testing-validate-not-null-handling

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Prove that customers.country rejects NULL while the optional city column accepts it.

Your task

  1. 1Try to insert name 'No Country', email 'no.country@example.com', country NULL, created_at '2025-06-01'; it must fail.
  2. 2Insert name 'City Optional', email 'city.optional@example.com', city NULL, country 'Canada', created_at '2025-06-01'; it must succeed.
  3. 3Verify: SELECT email, city FROM customers WHERE email IN ('no.country@example.com', 'city.optional@example.com').

Acceptance criteria

  • A statement fails with NOT NULL constraint failed
  • The last result set contains only the City Optional row with a NULL city

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 · Data validation basics