We consider the problem of query containment for XML queries with nesting. Given two queries, Q and Q , Q is said to be contained in Q if Q produces a subset of the answers of Q for any database instance. Query containment is important for query optimization, verification of integrity constraints, information integration and verification of knowledge bases. Query containment has been studied in the relational context and for XPath queries, but not for XML queries with nesting. We begin by considering conjunctive XML queries (c-XQueries), and show that containment is in PTIME if we restrict the fanout (number of sibling sub-blocks) to be 1. We show that for arbitrary fanout, containment is coNP-hard already for queries with nesting depth 2, even if the query does not include variables in the return clauses. We then show that for queries with fixed nesting depth, containment is coNP-complete. We consider several extensions to c-XQueries, including queries with union, negation and queries where the XPath expressions may include descendant edges (besides wildcards and branching). In each of these cases we show that even with fanout 1, query containment is coNP-complete, and query containment for queries with fixed nesting depth is still coNP-complete. Finally, we show that for queries with equalities on tag variables, containment is NP-complete for queries with fanout 1 and Π p 2 -complete for queries with arbitrary fanout but fixed nesting depth; for queries with arithmetic comparisons on tag variables, containment is Π p 2 -complete for both cases.
REF studies the complexity of the problem regarding completeness.
Containment of Nested XML Queries
VLDB
Computer Science