English

A Unifying Algorithm for Hierarchical Queries

Databases 2025-09-25 v2

Abstract

The class of hierarchical queries is known to define the boundary of the dichotomy between tractability and intractability for the following two extensively studied problems about self-join free Boolean conjunctive queries (SJF-BCQ): (i) evaluating a SJF-BCQ on a tuple-independent probabilistic database; (ii) computing the Shapley value of a fact in a database on which a SJF-BCQ evaluates to true. Here, we establish that hierarchical queries define also the boundary of the dichotomy between tractability and intractability for a different natural algorithmic problem, which we call the "bag-set maximization" problem. The bag-set maximization problem associated with a SJF-BCQ QQ asks: given a database D\cal D, find the biggest value that QQ takes under bag semantics on a database D\cal D' obtained from D\cal D by adding at most θ\theta facts from another given database Dr\cal D^r. For non-hierarchical queries, we show that the bag-set maximization problem is an NP-complete optimization problem. More significantly, for hierarchical queries, we show that all three aforementioned problems (probabilistic query evaluation, Shapley value computation, and bag-set maximization) admit a single unifying polynomial-time algorithm that operates on an abstract algebraic structure, called a "2-monoid". Each of the three problems requires a different instantiation of the 2-monoid tailored for the problem at hand.

Keywords

Cite

@article{arxiv.2506.10238,
  title  = {A Unifying Algorithm for Hierarchical Queries},
  author = {Mahmoud Abo Khamis and Jesse Comer and Phokion Kolaitis and Sudeepa Roy and Val Tannen},
  journal= {arXiv preprint arXiv:2506.10238},
  year   = {2025}
}
R2 v1 2026-07-01T03:12:16.947Z