A shop exports order records and wants to answer a familiar question: how much revenue did each region produce? Local Orders Lab keeps those records in the browser. The worker lessons build its JavaScript processing pipeline; this series adds a query engine so that filters, grouped totals, and later joins do not require another hand-written loop for every report. The same application gives us a reason to learn each abstraction.
Our teaching data is synthetic. Each order has an integer identifier, a region, and an amount in integer cents. The first milestone accepts three rows, stores them in SQLite, and returns a region summary. Later milestones put the database behind a worker, examine the byte boundary, explore genuine shared Wasm memory, and recover the database after a restart. JavaScript remains responsible for the interface and application policy throughout.
We use sql.js, an existing SQLite distribution compiled with Emscripten, instead of implementing a database. This tutorial deliberately pins sql.js 1.14.1. It is a reproducible teaching version, not a claim about the latest release. Its JavaScript loader and Wasm binary must come from that same release. The upstream releases and tagged source explain the provenance.
Why add a database when one JavaScript loop can already sum amounts? The three-row report alone does not justify one. The useful requirement is a growing set of queries over the same imported data: filter by region, group by amount range, join orders with a product catalog, and inspect the result without rebuilding a custom execution engine. SQLite supplies that language and implementation. If the product only needs a fixed sum over a short array, keep the JavaScript loop. Architecture follows the needed capability, not the novelty of the runtime.