Problemadvanced
Consistent query answering
Also called CQA, consistent answers over repairs.
Return the answers to a query that hold in every repair of an inconsistent database, without choosing one repair.
Consistent query answering asks which answers of a query are true in every repair of a database that violates its constraints. It differs from database repair: that problem builds one consistent database and runs queries on it, while consistent query answering keeps the data as it is and returns only what no choice of repair can change. The definition follows Arenas, Bertossi and Chomicki. Most of the theory is for primary keys, where a repair keeps exactly one fact of each group of facts with the same key.
In plain words
Two sources disagree about the department of Ann. One says sales and the other says HR, and the database cannot tell which is right. You can still answer questions. "Is Bob in HR?" gets yes if all sources agree on Bob. "Does Ann work somewhere?" gets yes, because she does in every reading. "Is Ann in HR?" gets no clear answer, so it is left out.
The answers you return are the safe ones: true whatever way the conflicts are settled. The hard part is that the number of ways to settle the conflicts grows very fast, so you cannot try them one by one. For some questions a clever rewrite of the question gives the safe answers directly. For others, no fast method is known.
Definition
Repairs. Let be a finite database and a set of constraints, for example primary keys, functional dependencies or denial constraints. Set semantics holds. A subset repair of is a subset that satisfies and is maximal under inclusion among such subsets. Denial constraints, and so primary keys and functional dependencies, are kept when facts are deleted, so at least one subset repair exists.
Consistent answers. For a query , a tuple is a consistent answer if for every subset repair of . For a Boolean query , the decision problem asks, given , whether is true in every repair. The query and the constraints are fixed, so the complexity is data complexity unless stated.
Primary keys. A schema with primary keys is written , with the key before the semicolon. A block is a maximal set of facts of one relation that agree on the key. Under primary keys, the subset repairs are exactly the sets that keep one fact from each block, so a database with blocks of sizes has repairs. Queries are conjunctive queries in AHV notation . The query is self-join-free if no relation name occurs twice.
Variants
- Constraints. Primary keys, functional dependencies, denial constraints, or constraints with insertions such as inclusion dependencies. With inclusion dependencies a repair may also add facts, and repairs are defined by a minimal symmetric difference.
- Repair semantics. Subset repairs, repairs with the largest number of facts, repairs by updates of values, or repairs with priorities among facts. Each gives a different set of consistent answers.
- Queries. Self-join-free conjunctive queries, queries with self-joins, unions, aggregates, or first-order queries. For an aggregate, the usual answer is the range of values over all repairs.
- Counting. Count the repairs in which the query is true, instead of asking if it is true in all of them.
Examples
Let hold (ann, sales), (ann, hr) and (bob, hr). The block of ann has two facts, so there are two repairs: {(ann, sales), (bob, hr)} and {(ann, hr), (bob, hr)}.
| query | answers in repair 1 | answers in repair 2 | consistent answers |
|---|---|---|---|
| bob | ann, bob | bob | |
| ann, bob | ann, bob | ann, bob | |
| sales | hr | none |
Three Boolean queries over and or show the three cases of the theory.
- First-order. with keyed on . It is true in every repair if and only if holds in . Each repair keeps one fact of the block of such an , and the block of for its is not empty, so the repair keeps an fact that joins. If no such exists, a repair that picks a bad in every block of makes false. So is a first-order query, and SQL can compute it.
- Polynomial but not first-order. with keyed on . Wijsen proved that is in polynomial time but has no first-order rewriting.
- coNP-complete. with keyed on , so the join is on two attributes outside the keys. is coNP-complete (Fuxman and Miller). The reduction is below.
Known algorithms
- Brute force. Enumerate the repairs and evaluate the query in each one. Correct for every query, but the number of repairs can be exponential in .
- First-order rewriting. For the queries where it exists, compute a first-order query with equal to the consistent answers, and run it as SQL. Arenas, Bertossi and Chomicki gave a rewriting by residues for some classes of constraints and queries. Fuxman and Miller gave a rewriting for a class of self-join-free conjunctive queries under primary keys, which contains .
- The attack graph. Koutris and Wijsen define, for a self-join-free conjunctive query, a graph on its atoms. It decides which case holds and, in the polynomial cases, guides the algorithm.
- The conflict hypergraph. Under denial constraints, the facts are the vertices and each minimal set of facts that violates a constraint is a hyperedge. The repairs are the maximal independent sets. Chomicki and Marcinkowski use it to answer queries without quantifiers in polynomial time.
- Solvers. For the coNP-complete cases, encode "some repair makes the query false" as a SAT instance, an integer program or an answer set program, and give it to a solver.
Bounds
All bounds are theorems in data complexity unless stated.
- Upper bound. Under denial constraints, is in coNP for every first-order . A certificate for "no" is a repair with false. Checking that is consistent takes polynomial time for fixed constraints. Checking that it is maximal needs only single facts: is maximal if and only if violates for each , since a consistent would make consistent for each .
- Hardness. is coNP-complete (Fuxman and Miller).
- Trichotomy for primary keys. For each self-join-free conjunctive query under primary keys, is in FO if the attack graph of is acyclic, coNP-complete if it has a strong cycle, and in P but not in FO otherwise (Koutris and Wijsen, TODS 2017). The case can be decided from .
- Logspace. The polynomial cases of the trichotomy can be expressed in symmetric stratified Datalog and so are in logspace (Koutris and Wijsen, 2021).
- Queries without quantifiers. Under denial constraints, the consistent answers to quantifier-free queries can be found in polynomial time (Chomicki and Marcinkowski).
- Combined complexity. If the query is part of the input, the problem is at least as hard as evaluating a Boolean conjunctive query, which is NP-complete: with empty the database is its own only repair.
Reductions
- From SAT to the complement of . Take a formula in conjunctive normal form. For each clause , put for each literal of , so the block of holds its literals. For each variable , put and , a block of two facts. A repair picks one literal per clause from and one literal per variable from , and is false in it if and only if no literal is picked by both. Read the pick as " is false" and as " is true". Then the picks are the false literals of an assignment, and fails if and only if each clause picks a true literal. So the formula is satisfiable if and only if some repair makes false. This gives the coNP-hardness.
- To SAT. In the other direction, "some repair makes false" is in NP and so reduces to SAT, which is how solvers are used.
- From certain answers. The consistent answers are the certain answers over the set of possible worlds given by the repairs. Data exchange and answering queries using views use the same idea with other sets of worlds.
Applications
- Data integration. Sources that agree on the schema can disagree on the values for one key. Consistent answers report only what holds whatever source is right.
- Querying dirty data without cleaning it. When no repair can be chosen with confidence, consistent answers give a safe subset of the answers. A probabilistic method such as HoloClean chooses values instead.
- Data quality checks. The difference between the plain answers and the consistent answers shows which answers depend on the conflicts.
References
- Marcelo Arenas, Leopoldo Bertossi and Jan Chomicki, Consistent query answers in inconsistent databases, PODS 1999, pages 68-79, the definition of repairs and consistent answers, and the rewriting by residues
- Ariel Fuxman and Renée J. Miller, First-order query rewriting for inconsistent databases, Journal of Computer and System Sciences 73(4), 2007, pages 610-635, the class of queries with a first-order rewriting under primary keys, and a coNP-complete query
- Jef Wijsen, A remark on the complexity of consistent conjunctive query answering under primary key violations, Information Processing Letters 110(21), 2010, pages 950-955, a query in polynomial time without a first-order rewriting
- Paraschos Koutris and Jef Wijsen, Consistent query answering for self-join-free conjunctive queries under primary key constraints, ACM TODS 42(2), 2017, the attack graph and the dichotomy between polynomial time and coNP-completeness
- Paraschos Koutris and Jef Wijsen, Consistent query answering for primary keys in Datalog, Theory of Computing Systems 65(1), 2021, the polynomial cases expressed in symmetric stratified Datalog and placed in logspace
- Jan Chomicki and Jerzy Marcinkowski, Minimal-change integrity maintenance using tuple deletions, Information and Computation 197(1-2), 2005, pages 90-121, the conflict hypergraph and the complexity of consistent answers under denial constraints
- Leopoldo Bertossi, Database Repairing and Consistent Query Answering, Morgan and Claypool, 2011, the chapters on consistent query answering and its complexity
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 17CGZ9 Edit this page History Report an error Markdown