Rewriting with Acyclic Queries: Mind Your Head
Gaetano Geck, Jens Keppeler, Thomas Schwentick, Christopher Spinrath
TL;DR
This paper investigates exact rewritability of conjunctive queries using views under acyclic, free-connex acyclic, hierarchical, and q-hierarchical restrictions. It introduces a cover-partition characterisation that reduces rewritability to decomposing the query body into parts matched to views, enabling constructive rewritings when possible. The authors prove that if a rewriting exists for an acyclic (or stronger) query class, then an acyclic (or corresponding) rewriting also exists, and they delineate a sharp complexity border: acyclic rewritability is tractable for bounded view arity or free-connex acyclic views but NP-hard when view arity is unbounded. They extend the analysis to hierarchical and q-hierarchical queries, showing existence results for rewritings and establishing NP-hardness in certain settings, with several open questions remaining (notably for unbounded schemas with q-hierarchical views). A tractable case is presented by reducing free-connex acyclic views to bounded-arity representations, enabling PTIME rewritability checks and constructions. Overall, the work provides a principled framework and practical guidance for deriving efficient rewritings over restricted view classes, and it highlights key open problems in the structure–complexity landscape of query rewriting.
Abstract
The paper studies the rewriting problem, that is, the decision problem whether, for a given conjunctive query $Q$ and a set $\mathcal{V}$ of views, there is a conjunctive query $Q'$ over $\mathcal{V}$ that is equivalent to $Q$, for cases where the query, the views, and/or the desired rewriting are acyclic or even more restricted. It shows that, if $Q$ itself is acyclic, an acyclic rewriting exists if there is any rewriting. An analogous statement also holds for free-connex acyclic, hierarchical, and q-hierarchical queries. Regarding the complexity of the rewriting problem, the paper identifies a border between tractable and (presumably) intractable variants of the rewriting problem: for schemas of bounded arity, the acyclic rewriting problem is NP-hard, even if both $Q$ and the views in $\mathcal{V}$ are acyclic or hierarchical. However, it becomes tractable if the views are free-connex acyclic (i.e., in a nutshell, their body is (i) acyclic and (ii) remains acyclic if their head is added as an additional atom).
