SQL (SQLite engine)

Verify data after a point-in-time restore

Expert190 pts~70 min
  • Point-in-time recovery
  • Change log replay
  • Restore verification
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-verify-data-after-a-point-in-time-restore

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

Objective

Recover product prices to the moment before an 11:00 incident by restoring a base backup and replaying the change log up to that point, then verify the recovered prices.

Your task

  1. 1Base backup: ATTACH DATABASE ':memory:' AS backup; CREATE TABLE backup.products AS SELECT * FROM products.
  2. 2Create change_log (id INTEGER PRIMARY KEY, changed_at TEXT NOT NULL, product_id INTEGER NOT NULL, new_price REAL NOT NULL). Apply and log: '2025-12-30 09:00' product 1 → 189.99, '2025-12-30 10:30' product 2 → 79.99, then the incident at '2025-12-30 11:00': every audio price set to 0 (log one row per product).
  3. 3Restore the base: UPDATE products SET price = (SELECT b.price FROM backup.products b WHERE b.id = products.id).
  4. 4Replay: for each product, apply its latest change_log entry with changed_at < '2025-12-30 11:00'.
  5. 5Verify: SELECT id, price FROM products WHERE category = 'audio'.

Acceptance criteria

  • Product prices equal the pre-incident state (only the 09:00 and 10:30 changes applied)
  • The last result set lists the recovered audio prices
  • The restore reads from backup.products

Constraints

  • Every run starts from a freshly seeded database, so your script must include its own setup statements.
  • An attached ':memory:' database stands in for the base backup; change_log stands in for the WAL/binlog.
  • Only the last result set of your script is compared, so finish with the verification query.

SQL (SQLite engine) · Database Testing · Performance, backup & recovery