Linear Programs with Conjunctive Queries

Authors Florent Capelli, Nicolas Crosetti, Joachim Niehren, Jan Ramon

Thumbnail PDF


  • Filesize: 0.94 MB
  • 19 pages

Document Identifiers

Author Details

Florent Capelli
  • Univ. Lille, Inria, CNRS, UMR 9189 - CRIStAL, F-59000 Lille, France
Nicolas Crosetti
  • Univ. Lille, Inria, CNRS, UMR 9189 - CRIStAL, F-59000 Lille, France
Joachim Niehren
  • Univ. Lille, Inria, CNRS, UMR 9189 - CRIStAL, F-59000 Lille, France
Jan Ramon
  • Univ. Lille, Inria, CNRS, UMR 9189 - CRIStAL, F-59000 Lille, France


We also thank Sylvain Salvati, Sophie Tison and Yuyi Wang for fruitful discussions and anonymous reviewers of a previous version of this paper for their helpful comments.

Cite AsGet BibTex

Florent Capelli, Nicolas Crosetti, Joachim Niehren, and Jan Ramon. Linear Programs with Conjunctive Queries. In 25th International Conference on Database Theory (ICDT 2022). Leibniz International Proceedings in Informatics (LIPIcs), Volume 220, pp. 5:1-5:19, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2022)


In this paper, we study the problem of optimizing a linear program whose variables are the answers to a conjunctive query. For this we propose the language LP(CQ) for specifying linear programs whose constraints and objective functions depend on the answer sets of conjunctive queries. We contribute an efficient algorithm for solving programs in a fragment of LP(CQ). The naive approach constructs a linear program having as many variables as there are elements in the answer set of the queries. Our approach constructs a linear program having the same optimal value but fewer variables. This is done by exploiting the structure of the conjunctive queries using generalized hypertree decompositions of small width to factorize elements of the answer set together. We illustrate the various applications of LP(CQ) programs on three examples: optimizing deliveries of resources, minimizing noise for differential privacy, and computing the s-measure of patterns in graphs as needed for data mining.

Subject Classification

ACM Subject Classification
  • Theory of computation → Logic and databases
  • Database queries
  • linear programming
  • hypergraph decomposition


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


  1. Guillaume Bagan, Arnaud Durand, and Etienne Grandjean. On acyclic conjunctive queries and constant delay enumeration. In International Workshop on Computer Science Logic, pages 208-222. Springer, 2007. Google Scholar
  2. Florent Capelli, Nicolas Crosetti, Joachim Niehren, and Jan Ramon. Linear Programs with Conjunctive Queries. In 25th Internationcal Conference on Database Theory (ICDT 2022), Edinburgh, United Kingdom, March 2022. URL:
  3. 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:
  4. Cynthia Dwork and Aaron Roth. The Algorithmic Foundations of Differential Privacy. Foundations and Trends in Theoretical Computer Science, 9(3-4):211-407, 2014. Google Scholar
  5. Robert Fourer, David M Gay, and Brian W Kernighan. A modeling language for mathematical programming. Management Science, 36(5):519-554, 1990. Google Scholar
  6. G. Gottlob, N. Leone, and F. Scarcello. Hypertree Decompositions and Tractable Queries. Journal of Computer and System Sciences, 64(3):579-627, May 2002. arXiv: cs/9812022. Google Scholar
  7. Georg Gottlob, Nicola Leone, and Francesco Scarcello. On tractable queries and constraints. In International Conference on Database and Expert Systems Applications, pages 1-15. Springer, 1999. Google Scholar
  8. Martin Grohe. The structure of tractable constraint satisfaction problems. In International Symposium on Mathematical Foundations of Computer Science, pages 58-72. Springer, 2006. Google Scholar
  9. Martin Grohe and Dániel Marx. Constraint solving via fractional edge covers. ACM Transactions on Algorithms (TALG), 11(1):4, 2014. Google Scholar
  10. Narendra Karmarkar. A new polynomial-time algorithm for linear programming. Comb., 4(4):373-396, 1984. URL:
  11. Ton Kloks. Treewidth: computations and approximations, volume 842. Springer Science & Business Media, 1994. Google Scholar
  12. Phokion G. Kolaitis, Enela Pema, and Wang-Chiew Tan. Efficient querying of inconsistent databases with binary integer programming. Proceedings of the VLDB Endowment, 6(6):397-408, April 2013. URL:
  13. Leonid Libkin. Elements of finite model theory. Springer Science & Business Media, 2013. Google Scholar
  14. Alexandra Meliou and Dan Suciu. Tiresias: The database oracle for how-to queries. In Proceedings of the 2012 ACM SIGMOD International Conference on Management of Data, SIGMOD '12, pages 337-348, New York, NY, USA, 2012. ACM. URL:
  15. Nicholas Nethercote, Peter J Stuckey, Ralph Becket, Sebastian Brand, Gregory J Duck, and Guido Tack. Minizinc: Towards a standard cp modelling language. In International Conference on Principles and Practice of Constraint Programming, pages 529-543. Springer, 2007. Google Scholar
  16. 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. Google Scholar
  17. 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. Google Scholar
  18. Reinhard Pichler and Sebastian Skritek. Tractable counting of the answers to conjunctive queries. Journal of Computer and System Sciences, 79:984-1001, September 2013. Google Scholar
  19. Laurynas Šikšnys and Torben Bach Pedersen. SolveDB: Integrating optimization problem solvers into SQL databases. In Proceedings of the 28th International Conference on Scientific and Statistical Database Management, page 14. ACM, 2016. Google Scholar
  20. Yuyi Wang, Jan Ramon, and Thomas Fannes. An efficiently computable subgraph pattern support measure: counting independent observations. Data Mining and Knowledge Discovery, 27(3):444-477, November 2013. Google Scholar
  21. 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