Maximally Contained Rewritings
- Maximally contained rewritings are a formal framework in query answering using views for CQACs, ensuring that only the certain answers are captured.
- They leverage a Datalog^AC transformation to manage arithmetic comparisons and apply inverse-rule methods for efficient query rewriting.
- The framework delineates tractable boundaries and complexity distinctions, which are crucial for effective data integration and information exchange.
Maximally contained rewritings (MCRs) are a central concept in the theory of query answering using views, particularly for conjunctive queries with arithmetic comparisons (CQACs). An MCR encodes all possible certain answers to a target query, leveraging contained rewritings over a specified set of views and is uniquely determined within a union-of-CQACs (U-CQAC) query language under the open-world assumption (OWA). This framework is critical in understanding both algorithmic feasibility and theoretical limitations in the presence of arithmetic constraints, especially those involving semi-interval (SI) comparisons.
1. Formal Framework and Definitions
Let
be a CQAC query over base schema , where are relational atoms and is a conjunction of arithmetic comparisons. A set of CQAC views $\V = \{V_1, \ldots, V_n\}$ is assumed, with each similarly defined.
A rewriting of using $\V$ is any CQAC whose atoms mention only predicates . 0 is a contained rewriting if, for every instance 1 (for some database 2),
3
A maximally contained rewriting 4 is a contained rewriting such that for every other contained rewriting 5 using 6 in language 7,
8
Equivalently, 9 is defined by the (possibly infinite) union of all contained rewritings: 0 This MCR captures precisely the certain answers to 1 with respect to view instance 2, i.e., 3, where
4
This characterization assures that MCRs do not overgenerate answers and are maximal among all contained rewritings in their expressive class (Afrati et al., 12 Sep 2025).
2. Containment and Expansion in CQACs
The containment property crucial for MCR construction is based on view-expansion. For a rewriting 5 with body view atoms 6, its expansion 7 is obtained by unfolding each 8 using its CQAC definition and suitably renaming variables. Containment then reduces to query containment in the CQAC sense: 9 Maximal containment requires that 0 subsumes every other contained rewriting, which corresponds to returning the intersection (across base instances) of what 1 could return given the constraints imposed by the views, in all completions consistent with the available view data.
3. Algorithmic Construction of MCRs
While Minicon-style algorithms suffice for plain conjunctive queries, CQACs introduce arithmetic complications. The paper identifies the prominent tractable subclass of CQACs—when 2 is in the class 3 (restricted to SI comparisons and at most one right-SI comparison).
The construction follows a two-stage process:
- Datalog4 Transformation: A 5 CQAC 6 is transformed into a Datalog7 program 8 by encoding SI comparisons as unary predicates (e.g., 9), including mapping rules for SI-ACs, coupling rules enforcing their Boolean structure, link rules for constants in comparisons, and transitive closure rules for the order predicate $\V = \{V_1, \ldots, V_n\}$0.
- Inverse-Rule MCR Construction: Each view is similarly transformed into a CQ using the new predicate symbols; existing Datalog MCR algorithms (e.g., the inverse-rule method) are then applied to compute the MCR in Datalog$\V = \{V_1, \ldots, V_n\}$1. The result is reverse-transformed back to a union of CQACs by interpreting the unary/binary predicates as their associated arithmetic comparison constraints.
Pseudocode summary: 3 The MCR constructed in this way is shown to be unique and correct for $\V = \{V_1, \ldots, V_n\}$2 queries with respect to the original CQAC views [(Afrati et al., 12 Sep 2025), Theorems 8.8 & 8.9].
4. Computational Complexity
The complexity of containment and MCR computation depends critically on the structure of arithmetic comparisons in $\V = \{V_1, \ldots, V_n\}$3 and the views. The following table (from Table 1 in the data) summarizes key dichotomies:
| CQACs Allowed in $\V = \{V_1, \ldots, V_n\}$4 | CQACs Allowed in $\V = \{V_1, \ldots, V_n\}$5 | Complexity |
|---|---|---|
| arbitrary CQAC | one AC + equality | NP |
| arbitrary CQAC | closed left-SI only | NP |
| arbitrary CQAC | SI + one RSI | NP |
| contains OSI, $\V = \{V_1, \ldots, V_n\}$6 | OSI only | $\V = \{V_1, \ldots, V_n\}$7-complete |
| etc. | etc. | $\V = \{V_1, \ldots, V_n\}$8-complete |
For queries where $\V = \{V_1, \ldots, V_n\}$9 (the containing query) uses at most one SI comparison or only (closed) left-SI or right-SI, containment is in NP. With open SI comparisons (OSI) or combination with inequality (0), the problem becomes 1-complete via reduction from 2-QBF [(Afrati et al., 12 Sep 2025), Theorems 4.1, 4.2, 5.1, 5.3]. The NP-membership proofs rely on the fact that only one containment mapping may be active, allowing for efficient certification (Lemma 5.4, Proposition 6.2).
5. MCRs and the Certain Answers Semantics
For CQACs, MCRs precisely capture all certain answers under the open-world assumption. That is, for any 3, 4, and view-instance 5: 6 This result holds for the language of U-CQAC, including possibly infinite unions. The proof is by maximality and containment: 7 includes every possible contained rewriting—thus capturing all certain answers—and does not admit any superfluous ones. In cases where MCRs can be effectively constructed and are finite, the evaluation is in polynomial time with respect to the data (8), as each CQAC can be evaluated in PTIME data-complexity [(Afrati et al., 12 Sep 2025), Theorem 7.1, Section 7].
6. Illustrative Examples
Two representative examples illustrate the mechanics and minimality property of MCRs:
Example 1:
9
Views: 0 No single view suffices. The MCR in U-CQAC is the union: 1 Each 2 is contained; any other contained rewriting is subsumed. 3 thus recovers all 4 with 5, and 6 in 7.
Example 2:
8
9
A contained (but non-minimal) rewriting: 0 Rectified to (by adding implied comparisons), yielding a minimal MCR: 1 Algorithmic construction via Datalog2 discovers such minimal self-join rewritings.
7. Significance and Research Context
MCRs provide a canonical solution for answering queries using views in the presence of arithmetic comparisons, particularly under the OWA and for data integration settings. The precise tractability boundaries for containment and certain answer computation, especially for SI and OSI comparisons, distinguish this framework from earlier purely relational cases. This aligns MCR computation for CQACs with seminal work by Chandra & Merlin (1977), Klug (1988), and others on query containment and rewriting, but uniquely addresses cases with arithmetic constraints (Afrati et al., 12 Sep 2025).
The correct and efficient computation of MCRs remains an active area in database theory, as highlighted in recent work by Afrati and Damigos and foundational approaches to inverse-rule rewriting (Duschka & Wagner, 1997). This suggests significant ongoing relevance for applications in probabilistic databases, information integration, and robust data exchange frameworks.