Algorithm Search⌘K

Definitionadvanced

Certain answers

Also called certain answer semantics.

The tuples that are answers to a query in every possible database consistent with the data and the mapping.

The certain answers of a query over incomplete data are the tuples that are answers in every complete database that the data allows. This page defines them for data exchange, data integration and tables with nulls, where the possible databases come from a mapping or from unknown values. Consistent query answering uses the same "true in all" idea over the repairs of an inconsistent database, and ontology-mediated query answering uses it over the models of an ontology. Here the data is consistent and there is no ontology: the unknowns are the values and the facts that the mapping leaves open.

Definition

Let W\mathcal W be a set of complete databases, the possible worlds. For a query qq of arity kk, the certain answers are

cert(q,W)=⋂W∈Wq(W).\mathrm{cert}(q, \mathcal W) = \bigcap_{W \in \mathcal W} q(W).

For a Boolean query, the certain answer is true if qq is true in every world. Set semantics holds. The set W\mathcal W comes from the setting.

  • Data exchange. For a schema mapping M\mathcal M and a source instance II, W\mathcal W is the set of solutions for II, and cert(q,I)\mathrm{cert}(q, I) is written for the certain answers.
  • Data integration. W\mathcal W is the set of global databases that agree with the sources under the GAV or LAV mapping.
  • Tables with nulls. A table TT holds constants and labeled nulls ⊥1,⊥2,…\bot_1, \bot_2, \ldots. A valuation vv replaces each null by a constant. Under the closed world assumption, W={v(T)}\mathcal W = \{ v(T) \} over all valuations. Under the open world assumption, W\mathcal W holds each database that contains some v(T)v(T).

The answers in cert(q,W)\mathrm{cert}(q, \mathcal W) contain only constants, since a tuple with a null is not an answer in a world where that null has two different values.

Naive evaluation. Evaluate qq on an instance with nulls as if each null were a constant different from all others, then drop each tuple that holds a null.

Theorem. Let qq be a union of conjunctive queries, written as rules Q(x) :- R1(u1),…,Rm(um)Q(x) \text{ :- } R_1(u_1), \ldots, R_m(u_m). Then the certain answers of qq are the result of naive evaluation:

  • on a table TT, under the open and under the closed world assumption (Imieliński and Lipski);
  • on any universal solution of a data exchange problem (Fagin, Kolaitis, Miller and Popa).

Why. A union of conjunctive queries is preserved by homomorphisms: if h:J→Wh : J \to W is the identity on constants and t∈q(J)t \in q(J), then h(t)∈q(W)h(t) \in q(W). A universal solution maps into each solution, so each null-free answer on it is an answer in each world. In the other direction, the universal solution with its nulls read as new constants is itself a possible world, so a certain answer is an answer there.

Complexity, in data complexity. For unions of conjunctive queries the certain answers take polynomial time in the settings above, with weakly acyclic target dependencies for data exchange. For some fixed conjunctive queries with inequalities they are coNP-complete under the open world assumption, and for some fixed conjunctive queries over views they are coNP-complete under the closed world assumption (Abiteboul and Duschka). With negation, naive evaluation is no longer correct.

Examples and non-examples

The mapping has d1:∀x,y (Flight(x,y)→∃z (Leg(x,z)∧Leg(z,y)))d_1 : \forall x, y\, (\text{Flight}(x, y) \to \exists z\, (\text{Leg}(x, z) \wedge \text{Leg}(z, y))) and d2:∀x,y (Flight(x,y)→∃u Leg(x,u))d_2 : \forall x, y\, (\text{Flight}(x, y) \to \exists u\, \text{Leg}(x, u)), and I={Flight(a,b),Flight(b,c)}I = \{\text{Flight}(a, b), \text{Flight}(b, c)\}. The chase gives the universal solution

J={Leg(a,⊥1),Leg(⊥1,b),Leg(b,⊥2),Leg(⊥2,c),Leg(a,⊥3),Leg(b,⊥4)}.J = \{\text{Leg}(a, \bot_1), \text{Leg}(\bot_1, b), \text{Leg}(b, \bot_2), \text{Leg}(\bot_2, c), \text{Leg}(a, \bot_3), \text{Leg}(b, \bot_4)\}.
query naive answers on JJ certain answers
Q(x,y) :- Leg(x,z),Leg(z,y)Q(x, y) \text{ :- } \text{Leg}(x, z), \text{Leg}(z, y) (a,b)(a, b), (b,c)(b, c) and tuples with nulls {(a,b),(b,c)}\{(a, b), (b, c)\}
Q(x) :- Leg(x,y)Q(x) \text{ :- } \text{Leg}(x, y) aa, bb, ⊥1\bot_1, ⊥2\bot_2 {a,b}\{a, b\}
Q(x,y) :- Leg(x,y)Q(x, y) \text{ :- } \text{Leg}(x, y) only tuples with nulls ∅\emptyset

The last row is the point of certain answers: each flight surely has two legs, but no single leg is known.

Non-example: negation. Let qq be the Boolean query "no xx has Leg(x,x)\text{Leg}(x, x)". Naive evaluation on JJ says true, since no fact of JJ has two equal values. But J1={Leg(a,b),Leg(b,b),Leg(b,c),Leg(c,c)}J_1 = \{\text{Leg}(a, b), \text{Leg}(b, b), \text{Leg}(b, c), \text{Leg}(c, c)\} is a solution, and there qq is false. So the certain answer is false, and naive evaluation on a universal solution is wrong for this query.

Non-example: possible answers. The tuple (a,c)(a, c) is an answer of the first query on the solution {Leg(a,d),Leg(d,b),Leg(b,d),Leg(d,c)}\{\text{Leg}(a, d), \text{Leg}(d, b), \text{Leg}(b, d), \text{Leg}(d, c)\}. It is a possible answer, true in some world, but not a certain one.

Non-example: SQL nulls. A table R={(a,NULL)}R = \{(a, \text{NULL})\} and the query "the xx with R(x,y)R(x, y) and (y=1y = 1 or y≠1y \neq 1)". In every world the condition is true, so aa is a certain answer. SQL gives each comparison with NULL the value unknown, and unknown or unknown is unknown, so SQL returns nothing. See SQL null semantics.

  • Possible answers. The union of q(W)q(W) over all worlds instead of the intersection.
  • Consistent answers. The intersection over the repairs of an inconsistent database; see consistent query answering and database repair.
  • Ontology-mediated answers. The intersection over the models of a set of data facts and an ontology; see ontology-mediated query answering.
  • Answering queries using views. For LAV sources, a maximally contained rewriting of a conjunctive query computes its certain answers; see answering queries using views.
  • Closed world semantics for data exchange. Restricting the worlds to those justified by the mapping changes the certain answers of queries with negation.

References

  1. Tomasz Imieliński and Witold Lipski, Incomplete information in relational databases, Journal of the ACM 31(4), 1984, pages 761-791, tables with nulls and the answers that hold in every represented database
  2. Ronald Fagin, Phokion G. Kolaitis, Renée J. Miller and Lucian Popa, Data exchange: semantics and query answering, Theoretical Computer Science 336(1), 2005, certain answers in data exchange and naive evaluation on universal solutions
  3. Serge Abiteboul and Oliver M. Duschka, Complexity of answering queries using materialized views, PODS 1998, pages 254-263, certain answers under the open and the closed world assumption
  4. Maurizio Lenzerini, Data integration: a theoretical perspective, PODS 2002, pages 233-246, certain answers in data integration
  5. Marcelo Arenas, Pablo Barceló, Leonid Libkin and Filip Murlak, Foundations of Data Exchange, Cambridge University Press, 2014, Chapter 7, Query answering and rewriting, and Chapter 8, Alternative semantics

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/ZTKR4H/text.yaml