Case Studies: Overview
The tutorial introduces the core workflow – add provenance to a table, run a query, evaluate the result in a semiring – on a single small example. The case studies are further worked examples, each built around a realistic dataset and centred on a different aspect of ProvSQL.
Each case study states its scenario and tasks up front and can be read
on its own. Most ship a single setup.sql to download and load; case
study 3 explains how to fetch the Île-de-France GTFS dataset (too large
to bundle), and case study 4 loads the data files under
doc/casestudy4/data/ in the source tree. The coverage matrix at the end of this page shows which study
demonstrates a given feature.
Tip
No install required. Every case study here except case study 3 (whose
GTFS dataset is too large to bundle) runs in the ProvSQL Playground, the browser build of ProvSQL Studio,
on a ready-made database. All but case studies 3 and 4 also ship as
runnable notebooks; each chapter links
to what it has. The Playground bundles no external tools, so
steps that explicitly call an external knowledge compiler (d4,
c2d…) or graph-easy do not run there, but the built-in methods
and everything else do. See the Playground note.
What each case study covers
- Case study 1 – Intelligence Agency
The broadest tour of provenance evaluation: a security-classification scenario over seven agents drives a custom min-clearance semiring, where-provenance, circuit export, and the full probability-method line-up side by side (possible-worlds, Monte-Carlo, tree-decomposition, and knowledge compilation through
d4/c2d/dsharp/minic2d), ending on revising a probability already used withreplace_input. Start here for a panoramic view.- Case study 2 – Open Science Database
Evidence synthesis over a fictional biomedical corpus – single-source vs. replicated claims, contradictions, strength-of-evidence ranking. The home of Shapley and Banzhaf values, attributing a result to the studies behind it.
- Case study 3 – Île-de-France Public Transit
Provenance at real-world scale. On the STIF GTFS dataset (hundreds of routes, tens of thousands of stops) a result token is true iff every record along the trip carries the accessibility flag – which stops are reachable from Luxembourg by a fully wheelchair-accessible journey? Then recursion over the whole network: one
WITH RECURSIVEquery answers travel times, accessible journeys and the probability of getting there through disruptions, each semiring solving its equations by its own method.- Case study 4 – Government Ministers Over Time
The temporal extension and data-modification tracking. Over French and Singaporean ministers every fact carries a validity interval; the study time-travels, takes history and timeslices, and rolls back an
INSERT/DELETEround-trip withundo.- Case study 5 – Wildlife Photo Archive
Uncertainty from a machine-learning detector: block-correlated alternatives via
repair_keyand themulinputgate, with candidate species per bounding box. It contrasts probabilistic ranking against naive confidence thresholding, computes expected species counts withexpected, and closes on NULL semantics:EXCEPT,NOT IN,NOT EXISTSand an outer join giving three genuinely different – and possible-worlds-correct – answers over unidentified detections, andINTERSECTagainst= ANYfor the positive question.- Case study 6 – City Air-Quality Sensor Network
Continuous distributions end to end:
random_variablecolumns (Normal / Uniform / Exponential / Erlang noise models, joined by the Gamma / Weibull / Pareto constructors and Bernoulli mixtures), arithmetic, comparison, andCASEon them, analytic moments with Monte-Carlo fallback, conditional inference, order statistics and quantiles, fleet statistics under sensor dropout (percentile_cont,corr), aCASE-over-aggregates triage headline, mutual information, and NULL (offline-sensor) readings. The first study driven primarily through ProvSQL Studio.- Case study 7 – Peer-Review Assignment and Knowledge Compilation
How a query’s shape, the schema’s keys, and the structure of the data decide which probability method is cheap and which needs a compiler. A peer-reviewing scenario organised by where tractability comes from: the query is safe (the four Dalvi-Suciu routes, including the Möbius-cancellation witness
), the query is
-hard (the knowledge-compilation pipeline), or the data is well-structured (the joint-width compiler and recursive network reliability).
- Case study 8 – ProvSQL as a Probability Calculator
ProvSQL as an exact, correlation-aware probability calculator driven in SQL. It answers textbook problems with one-line queries (the conditioning ones through the
|(“given”) operator): the base-rate fallacy, correlation breaking the independence formula, the method portfolio and its cost chooser, a continuous posterior by truncation, the conditional expectation of an aggregate, denial constraints as evidence, a skewed waiting time (log-normal, quantiles, transforms), discrete counts with a Beta rate posterior, the information gain of a Bayesian update (entropy, KL), a Gaussian-mixture cohort, empirically-loaded posteriors and forecast tables, and full Bayesian inference: a latent (random_variable) distribution parameter updated from data by likelihood weighting (observe/and_agg/evidence).- Case study 9 – A Sales Forecast Dashboard
Aggregates over uncertain data, the queries of an ordinary dashboard over deals that close with some probability: expected revenue with and without the regions that close nothing,
ROLLUPsubtotals, shares of a total, the leading region and each region’s rank, comparisons with a target, aNULLIFpercentage, aggregates of aggregates, grouping by an aggregate’s value,DISTINCT ON, andplainfor a value meant without provenance.
Feature coverage matrix
The tables below cross-reference every user-facing feature documented under the User Guide against the tutorial and the nine case studies.
Columns:
T – Tutorial (Who Killed Daphine?)
1 – Case study 1 (Intelligence Agency)
2 – Case study 2 (Open Science Database)
3 – Case study 3 (Île-de-France Public Transit)
4 – Case study 4 (Government Ministers Over Time)
5 – Case study 5 (Wildlife Photo Archive)
6 – Case study 6 (City Air-Quality Sensor Network)
7 – Case study 7 (Peer-Review Assignment and Knowledge Compilation)
8 – Case study 8 (ProvSQL as a Probability Calculator)
9 – Case study 9 (A Sales Forecast Dashboard)
Cells: ✓ the feature is exercised; (✓) it is mentioned in
passing but not actually executed; empty means it is not covered. The
administration features (the circuit store and its maintenance,
replication, the gate cache) are shown in their reference pages, not in a
case study.
Setup and basics
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
|
✓ |
✓ |
✓ |
|||||||
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
|
✓ |
|||||||||
Hand-built mapping table |
✓ |
✓ |
||||||||
|
(✓) |
(✓) |
(✓) |
(✓) |
(✓) |
(✓) |
||||
|
✓ |
|||||||||
|
Supported SQL constructs
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
|
|
||||||||||
Self-join |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
Subqueries in |
✓ |
✓ |
✓ |
✓ |
||||||
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
|
|
✓ |
✓ |
✓ |
✓ |
✓ |
|||||
|
✓ |
✓ |
✓ |
✓ |
||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
✓ |
|||||||
|
✓ |
✓ |
||||||||
CTE ( |
✓ |
✓ |
✓ |
|||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
|
||||||||||
Provenance-bearing view |
✓ |
✓ |
✓ |
|||||||
|
✓ |
|||||||||
Outer join ( |
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Quantified comparison ( |
✓ |
|||||||||
Scalar subquery |
✓ |
✓ |
✓ |
|||||||
|
||||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
✓ |
✓ |
|||||||
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
Window functions ( |
✓ |
|||||||||
Aggregates as window functions ( |
✓ |
|||||||||
|
✓ |
NULL values and zero-annotated rows
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
(✓) |
|||||||||
NULL-discriminating idioms ( |
✓ |
|||||||||
NULL |
✓ |
Aggregation
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
|
✓ |
|||||||||
Statistic aggregates over |
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Arithmetic / cast on aggregate result |
✓ |
✓ |
||||||||
Provenance-preserving |
✓ |
|||||||||
|
✓ |
|||||||||
|
||||||||||
|
✓ |
|||||||||
|
||||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Functions of an aggregate result ( |
✓ |
|||||||||
|
✓ |
|||||||||
Aggregate of an aggregate result ( |
✓ |
|||||||||
|
✓ |
✓ |
||||||||
Comparison over an aggregate in the |
✓ |
|||||||||
Ranking groups by an aggregate ( |
✓ |
|||||||||
|
Circuit inspection
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
(✓) |
✓ |
||||||||
|
Knowledge compilation and safe queries
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
✓ |
|||||||||
Bounded-treewidth network reliability (recursive reachability) |
✓ |
|||||||||
|
✓ |
|||||||||
Safe-query rewriter (hierarchical / read-once) |
✓ |
|||||||||
Joint-width UCQ compiler (bounded joint treewidth) |
✓ |
|||||||||
Möbius-inversion route (safe-by-cancellation UCQ) |
✓ |
|||||||||
Tseytin CNF export (DIMACS) |
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Inversion-free certificate ( |
✓ |
|||||||||
External-tool registry ( |
(✓) |
|||||||||
|
||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
|
Semiring evaluation
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
|
✓ |
✓ |
✓ |
|||||||
|
✓ |
(✓) |
||||||||
|
(✓) |
|||||||||
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Custom semiring via |
✓ |
Probabilities
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
Conditioning operator |
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
(✓) |
✓ |
✓ |
✓ |
||||||
|
✓ |
✓ |
✓ |
|||||||
|
(✓) |
✓ |
✓ |
✓ |
✓ |
✓ |
||||
|
(✓) |
✓ |
✓ |
✓ |
✓ |
|||||
|
(✓) |
✓ |
✓ |
|||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
Guarantee request ( |
✓ |
|||||||||
|
||||||||||
Studio benchmark panel |
✓ |
|||||||||
|
✓ |
✓ |
✓ |
✓ |
||||||
|
✓ |
✓ |
✓ |
|||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
||||||||||
|
✓ |
|||||||||
|
✓ |
Continuous random variables
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
Discrete counts ( |
✓ |
|||||||||
|
✓ |
|||||||||
Latent ( |
✓ |
|||||||||
|
✓ |
|||||||||
Arithmetic on |
✓ |
|||||||||
Order statistics ( |
✓ |
|||||||||
Transforms |
✓ |
|||||||||
|
✓ |
|||||||||
Comparison |
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
||||||||
Conditional inference via |
✓ |
✓ |
||||||||
Likelihood-weighting posterior ( |
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
||||||||||
|
||||||||||
|
✓ |
Shapley and Banzhaf values
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
Where-provenance
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
✓ |
||||||||
|
✓ |
✓ |
Data-modification tracking
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
Temporal features
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
✓ |
|||||||||
|
Export and visualisation
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
|
✓ |
|||||||||
|
✓ |
|||||||||
|
(✓) |
|||||||||
|
ProvSQL Studio
Feature |
T |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|---|---|---|---|---|---|---|---|---|---|---|
Circuit mode |
(✓) |
(✓) |
✓ |
✓ |
(✓) |
|||||
Contributions mode |
✓ |
|||||||||
Where mode |
(✓) |
✓ |
||||||||
Temporal mode |
✓ |
|||||||||
Notebook mode |
✓ |