Direct Access for Conjunctive Queries with Negations

Authors Florent Capelli , Oliver Irwin

Thumbnail PDF


  • Filesize: 0.95 MB
  • 20 pages

Document Identifiers

Author Details

Florent Capelli
  • Univ. Artois, CNRS, UMR 8188, Centre de Recherche en Informatique de Lens (CRIL), F-62300 Lens, France
Oliver Irwin
  • Université de Lille, CNRS, Inria, UMR 9189 - CRIStAL, F-59000 Lille, France


We are thankful to Stefan Mengel and Sylvain Salvati for helpful discussions while elaborating these results.

Cite AsGet BibTex

Florent Capelli and Oliver Irwin. Direct Access for Conjunctive Queries with Negations. In 27th International Conference on Database Theory (ICDT 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 290, pp. 13:1-13:20, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


Given a conjunctive query Q and a database 𝐃, a direct access to the answers of Q over 𝐃 is the operation of returning, given an index j, the j-th answer for some order on its answers. While this problem is #P-hard in general with respect to combined complexity, many conjunctive queries have an underlying structure that allows for a direct access to their answers for some lexicographical ordering that takes polylogarithmic time in the size of the database after a polynomial time precomputation. Previous work has precisely characterised the tractable classes and given fine-grained lower bounds on the precomputation time needed depending on the structure of the query. In this paper, we generalise these tractability results to the case of signed conjunctive queries, that is, conjunctive queries that may contain negative atoms. Our technique is based on a class of circuits that can represent relational data. We first show that this class supports tractable direct access after a polynomial time preprocessing. We then give bounds on the size of the circuit needed to represent the answer set of signed conjunctive queries depending on their structure. Both results combined together allow us to prove the tractability of direct access for a large class of conjunctive queries. On the one hand, we recover the known tractable classes from the literature in the case of positive conjunctive queries. On the other hand, we generalise and unify known tractability results about negative conjunctive queries - that is, queries having only negated atoms. In particular, we show that the class of β-acyclic negative conjunctive queries and the class of bounded nest set width negative conjunctive queries admit tractable direct access.

Subject Classification

ACM Subject Classification
  • Information systems → Relational database model
  • Conjunctive queries
  • factorized databases
  • direct access
  • hypertree decomposition


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Guillaume Bagan. Algorithmes et complexité des problèmes d’énumération pour l’évaluation de requêtes logiques. (Algorithms and complexity of enumeration problems for the evaluation of logical queries). PhD thesis, University of Caen Normandy, France, 2009. URL:
  2. Guillaume Bagan, Arnaud Durand, Etienne Grandjean, and Frédéric Olive. Computing the jth solution of a first-order query. RAIRO-Theoretical Informatics and Applications, 42(1):147-164, 2008. URL:
  3. Nurzhan Bakibayev, Tomáš Kočiskỳ, Dan Olteanu, and Jakub Závodnỳ. Aggregation and ordering in factorised databases. Proceedings of the VLDB Endowment, 6(14):1990-2001, 2013. URL:
  4. Johann Brault-Baron. De la pertinence de l’énumération: complexité en logiques propositionnelle et du premier ordre. PhD thesis, Université de Caen, 2013. URL:
  5. Johann Brault-Baron. Hypergraph acyclicity revisited. ACM Computing Surveys (CSUR), 49(3):1-26, 2016. URL:
  6. Johann Brault-Baron, Florent Capelli, and Stefan Mengel. Understanding model counting for beta-acyclic CNF-formulas. In 32nd International Symposium on Theoretical Aspects of Computer Science, volume 30 of LIPIcs, pages 143-156. Schloss Dagstuhl, 2015. URL:
  7. Karl Bringmann, Nofar Carmeli, and Stefan Mengel. Tight fine-grained bounds for direct access on join queries. In Proceedings of the 41st ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 427-436, 2022. URL:
  8. Karl Bringmann, Nofar Carmeli, and Stefan Mengel. Tight fine-grained bounds for direct access on join queries. arXiv preprint arXiv:2201.02401, 2022. URL:
  9. Florent Capelli. Understanding the complexity of #SAT using knowledge compilation. In 32nd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2017, Reykjavik, Iceland, June 20-23, 2017, pages 1-10. IEEE Computer Society, 2017. URL:
  10. Florent Capelli and Oliver Irwin. Direct access for conjunctive queries with negation. CoRR, abs/2310.15800, 2023. URL:
  11. Clément Carbonnel, Miguel Romero, and Stanislav Živnỳ. Point-width and max-csps. ACM Transactions on Algorithms (TALG), 16(4):1-28, 2020. URL:
  12. Nofar Carmeli, Nikolaos Tziavelis, Wolfgang Gatterbauer, Benny Kimelfeld, and Mirek Riedewald. Tractable orders for direct access to ranked answers of conjunctive queries. ACM Transactions on Database Systems, jan 2023. URL:
  13. Nofar Carmeli, Shai Zeevi, Christoph Berkholz, Benny Kimelfeld, and Nicole Schweikardt. Answering (unions of) conjunctive queries using random access and random-order enumeration. In Proceedings of the 39th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 393-409, 2020. URL:
  14. Ashok K. Chandra and Philip M. Merlin. Optimal implementation of conjunctive queries in relational data bases. In Proceedings of the Ninth Annual ACM Symposium on Theory of Computing, STOC '77, pages 77-90, New York, NY, USA, 1977. ACM. URL:
  15. Idan Eldar, Nofar Carmeli, and Benny Kimelfeld. Direct access for answers to conjunctive queries with aggregation. arXiv preprint, 2023. URL:
  16. Johannes K Fichte, Markus Hecher, Neha Lodha, and Stefan Szeider. An smt approach to fractional hypertree width. In Principles and Practice of Constraint Programming: 24th International Conference, CP 2018, Lille, France, August 27-31, 2018, Proceedings 24, pages 109-127. Springer, 2018. URL:
  17. Robert Ganian, André Schidler, Manuel Sorge, and Stefan Szeider. Threshold treewidth and hypertree width. Journal of Artificial Intelligence Research, 74:1687-1713, 2022. URL:
  18. Georg Gottlob and Reinhard Pichler. Hypergraphs in model checking: Acyclicity and hypertree-width versus clique-width. SIAM Journal on Computing, 33(2):351-378, 2004. URL:
  19. Martin Grohe and Dániel Marx. Constraint solving via fractional edge covers. ACM Transactions on Algorithms (TALG), 11(1):4, 2014. URL:
  20. Jinbo Huang and Adnan Darwiche. DPLL with a Trace: From SAT to Knowledge Compilation. In Proceedings of the Nineteenth International Joint Conference on Artificial Intelligence, pages 156-162, 2005. URL:
  21. Manas R Joglekar, Rohan Puttagunta, and Christopher Ré. Ajar: Aggregations and joins over annotated relations. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 91-106, 2016. URL:
  22. Jens Keppeler. Answering Conjunctive Queries and FO+MOD Queries under Updates. PhD thesis, Humboldt-Universität zu Berlin, Mathematisch-Naturwissenschaftliche Fakultät, 2020. URL:
  23. Mahmoud Abo Khamis, Hung Q Ngo, and Atri Rudra. Faq: questions asked frequently. arXiv preprint, 2015. URL:
  24. Mahmoud Abo Khamis, Hung Q Ngo, and Atri Rudra. Faq: questions asked frequently. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems, pages 13-28, 2016. URL:
  25. Matthias Lanzinger. Tractability beyond β-acyclicity for conjunctive queries with negation and sat. Theoretical Computer Science, 942:276-296, 2023. URL:
  26. Dan Olteanu. Factorized databases: A knowledge compilation perspective. In AAAI Workshop: Beyond NP, 2016. URL:
  27. Dan Olteanu and Jakub Závodnỳ. Factorised representations of query results: size bounds and readability. In Proceedings of the 15th International Conference on Database Theory, pages 285-298. ACM, 2012. URL:
  28. Dan Olteanu and Jakub Závodnỳ. Size bounds for factorised representations of query results. ACM Transactions on Database Systems (TODS), 40(1):1-44, 2015. URL:
  29. S. Ordyniak, D. Paulusma, and S. Szeider. Satisfiability of acyclic and almost acyclic CNF formulas. Theoretical Computer Science, 481:85-99, 2013. URL:
  30. Reinhard Pichler and Sebastian Skritek. Tractable counting of the answers to conjunctive queries. Journal of Computer and System Sciences, 79:984-1001, sep 2013. URL:
  31. Tian Sang, Fahiem Bacchus, Paul Beame, Henry A Kautz, and Toniann Pitassi. Combining component caching and clause learning for effective model counting. Theory and Applications of Satisfiability Testing, 2004. URL:
  32. Maximilian Schleich, Dan Olteanu, and Radu Ciucanu. Learning linear regression models over factorized joins. In Proceedings of the 2016 International Conference on Management of Data, pages 3-18. ACM, 2016. URL:
  33. Mihalis Yannakakis. Algorithms for acyclic database schemes. In Proceedings of the Seventh International Conference on Very Large Data Bases - Volume 7, VLDB '81, pages 82-94. VLDB Endowment, 1981. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail