Reverse engineering Conjunctive Queries (CQs) from examples is a computationally intensive task, traditionally classified as coNEXPTIME-complete. This paper investigates the mathematical bottlenecks of this complexity and proposes "relaxations"—specifically existential pebble games and desynchronized products—to reduce the complexity to more manageable classes like EXPTIME, coNP, or even polynomial time, while maintaining a rigorous link to query structures such as bounded treewidth.
The Challenge of Query-by-Example
In modern data management, a common hurdle is the gap between a user's intent and their technical proficiency. Users often know exactly which data they want—represented as a set of positive and negative examples—but lack the expertise to write formal SQL or Conjunctive Queries (CQs). This scenario defines the Query-by-Example (QBE) or definability problem: finding a query that perfectly fits a given set of examples.
Problem Formalization
The paper formally defines these reverse engineering tasks to establish a baseline for complexity analysis.
For standard CQs, this task is coNEXPTIME-complete. As the database size or the number of examples increases, the computational cost grows at a rate that renders the process impractical for real-world applications.
Identifying Complexity Bottlenecks
The authors isolate two primary sources of this "prohibitively high" complexity in the standard QBE test:
- The Direct Product Construction: Generating a "canonical" query from multiple positive examples requires a synchronized direct product of databases, which grows exponentially.
- The Homomorphism Test: Determining if this massive query matches negative examples is an NP-complete problem, leading to a second exponential blow-up.
Proposed Relaxations and Methods
To alleviate these bottlenecks, the paper introduces two key theoretical techniques:
- Existential Pebble Games: Instead of a strict homomorphism check, the authors utilize $(k+1)$-pebble games from finite model theory. This approximates structural similarity and characterizes queries with bounded treewidth—a class known for efficient evaluation.
- Desynchronization: Rather than seeking a single CQ that covers all examples simultaneously, the authors "desynchronize" the process. By treating examples in isolation, the target shifts from a single CQ to a Union of Conjunctive Queries (UCQ).
Key Insights and Results
The research yields several significant findings regarding the complexity of these relaxed problems:
- Treewidth and Pebble Games: Using pebble games in the QBE test perfectly characterizes whether a query exists within the class of CQs with treewidth at most $k$. This relaxation brings the complexity down to EXPTIME-complete.
- The Power of Unions: Desynchronizing examples to find a UCQ drops the complexity from coNEXPTIME to coNP-complete.
- Achieving Tractability: Combining both relaxations—pebble games and desynchronization—allows for the identification of a Union of CQs with bounded treewidth (UTW) in Polynomial Time.
- Graph Database Extensions: The authors extend these results to Conjunctive Regular Path Queries (CRPQs). They prove that QBE for CRPQs is in coNEXPTIME, providing a tighter upper bound than previous estimates of EXPSPACE.
Conclusion and Future Directions
This work provides a theoretical roadmap for making query reverse engineering more efficient. By identifying specific mathematical relaxations, the authors demonstrate that the "prohibitive" complexity of QBE can be tamed. Future research may focus on narrowing the complexity bounds for graph queries (CRPQs) and developing frameworks for "noisy" data where a perfect query might not exist, requiring an approximate explanation instead.
Summary updated