Efficiently Computing Provenance Graphs for Queries with Negation

Seokki Lee, Sven Köhler, Bertram Ludäscher, Boris GlavicarXiv 2017

Introduction

In modern database systems, understanding the "why" behind a query result is as critical as the result itself. Provenance provides this explanation by tracking which input tuples contributed to an output. However, traditional models struggle with queries involving negation—for example, identifying students who enrolled in one course but not another. In such cases, the presence of an answer depends on the absence of others, requiring a unified approach to "why" and "why-not" provenance. This paper presents a practical framework that achieves this unification through a novel Datalog rewriting technique, offering significant performance gains over previous theoretical models.

A Unified Provenance Model

The authors propose a graph-based model where nodes represent tuples, rules, or goals. To handle negation, the model uses color-coding: green nodes signify "success" (data exists or a rule was satisfied), while red nodes signify "failure" (data is missing or a rule was not satisfied).

Unified provenance graph showing successful (green) and failed (red) derivations.

As shown in the figure above, the graph structure allows the system to trace the dependencies between successful and failed components of a query. This unified representation is essential for queries with negation, where a "why" explanation for a result might include "why-not" sub-explanations for its negated conditions.

Methodology: Firing Rules and Pruning

The core technical contribution is a multi-step transformation process implemented in the GProM middleware. The system extends "firing rules" (a Datalog rewriting technique) to capture not only successful derivations but also the specific variable bindings that lead to failure.

To avoid the "open world" problem of instantiating every possible combination of data, the framework employs several optimizations:

  1. Top-Down Unification: Constants from a user's specific question (e.g., "Why is user X missing?") are propagated downward to prune irrelevant data early.
  2. Success/Failure Annotations: The algorithm identifies which nodes must have succeeded or failed to satisfy the user's query, narrowing the search space.
  3. Connectivity Joins: This step ensures that the resulting graph fragments are logically connected to the original question, eliminating "dangling" or irrelevant explanations.

Explaining Absence (Why-Not Provenance)

One of the most challenging aspects of database provenance is explaining why a result is not present. Previous models often required exhaustive instantiation of the entire provenance "game," which is computationally prohibitive for large datasets.

A provenance graph illustrating a "why-not" explanation where all paths to a result failed.

By treating the provenance question as a filter, the proposed system transforms a global search into a local, efficient lookup. As illustrated in the figure above, a "why-not" explanation can be represented as a graph where all paths leading to the potential result are marked as failures (red).

Performance and Scalability

The approach was evaluated using the DBLP co-author graph and the TPC-H industry benchmark. While previous "Direct Methods" failed on datasets larger than 10,000 tuples, this framework scaled to datasets of 10GB and 8 million tuples.

For "why" questions, the overhead scales linearly with dataset size. For the more complex "why-not" questions, the system provides answers in seconds, whereas exhaustive methods typically time out. By compiling the provenance logic into standard SQL, the system leverages existing RDBMS optimizations, making it highly practical for real-world applications.

Conclusion

This framework represents the first practical solution for computing provenance for queries with negation. By unifying "why" and "why-not" explanations into a single, pruned graph model, the authors provide a scalable way for users to debug complex database queries. Future work will focus on summarizing these graphs for better human readability and extending support to aggregation and recursive queries.

Summary updated

BibTeX
@misc{lee2017efficiently,
  author = {Seokki Lee and Sven Köhler and Bertram Ludäscher and Boris Glavic},
  title = {{Efficiently Computing Provenance Graphs for Queries with Negation}},
  year = {2017},
  eprint = {1701.05699},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1701.05699},
}
Figure