Theory of Computing Systems

, Volume 61, Issue 1, pp 2–30

Answering Conjunctive Queries with Inequalities

  • Paraschos Koutris
  • Tova Milo
  • Sudeepa Roy
  • Dan Suciu
Article
  • 45 Downloads

Abstract

In this paper, we study the complexity of answering conjunctive queries (CQ) with inequalities (≠). In particular, we are interested in comparing the complexity of the query with and without inequalities. The main contribution of our work is a novel combinatorial technique that enables us to use any Select-Project-Join query plan for a given CQ without inequalities in answering the CQ with inequalities, with an additional factor in running time that only depends on the query. The key idea is to define a new projection operator, which keeps a small representation (independent of the size of the database) of the set of input tuples that map to each tuple in the output of the projection; this representation is used to evaluate all the inequalities in the query. Second, we generalize a result by Papadimitriou and Yannakakis (1997) and give an alternative algorithm based on the color-coding technique (2008) to evaluate a CQ with inequalities by using an algorithm for the CQ without inequalities. Third, we investigate the structure of the query graph, inequality graph, and the augmented query graph with inequalities, and show that even if the query and the inequality graphs have bounded treewidth, the augmented graph not only can have an unbounded treewidth but can also be NP-hard to evaluate. Further, we illustrate classes of queries and inequalities where the augmented graphs have unbounded treewidth, but the CQ with inequalities can be evaluated in poly-time. Finally, we give necessary properties and sufficient properties that allow a class of CQs to have poly-time combined complexity with respect to any inequality pattern. We also illustrate classes of queries where our query-plan-based technique outperforms the alternative approaches discussed in the paper.

Keywords

Query evaluation Conjunctive query Inequality Treewidth 

References

  1. Abiteboul, S., Hull, R., Vianu, V.: Foundations of databases Addison-Wesley, 1995.Google Scholar
  2. Afrati, F., Li, C., Mitra, P.: Answering Queries Using Views with Arithmetic Comparisons. PODS, 209–220 (2002).Google Scholar
  3. Alon, N., Yuster, R., Zwick, U.: Finding and counting given length cycles. Algorithmica. 17 (3), 209–223 (1997).MathSciNetCrossRefMATHGoogle Scholar
  4. Alon, N., Yuster, R., Zwick, U.: Color Coding. Encyclopedia of Algorithms. Edited by: Kao, M.Y. Springer (2008).Google Scholar
  5. Atserias, A., Grohe, M., Marx, D.: Size bounds and query plans for relational joins. FOCS 739–748, 2008.Google Scholar
  6. Chekuri, C., Rajaraman, A.: Conjunctive query containment revisited. Theor. Comput. Sci. 239 (2), 211–229 (2000).MathSciNetCrossRefMATHGoogle Scholar
  7. Demange, M., De Werra, D.: On some coloring problems in grids. Theor. Comput. Sci. 472, 9–27 (2013).MathSciNetCrossRefMATHGoogle Scholar
  8. Durand, A., Grandjean, E.: The complexity of acyclic conjunctive queries revisited coRR abs/cs/0605008, 2006.Google Scholar
  9. Flum, J., Frick, M., Grohe, M.: Query evaluation via tree-decompositions. J. ACM. 49 (6), 716–752 (2002).MathSciNetCrossRefMATHGoogle Scholar
  10. Gottlob, G., Leone, N., Scarcello, F.: Hypertree Decompositions and Tractable Queries. PODS, 21–32 (1999).Google Scholar
  11. Graham, M.: On the Universal Relation. Technical Report. University of Toronto, Ontario (1979).Google Scholar
  12. Grohe, M., Marx, D.: Constraint Solving via Fractional Edge Covers. SODA, 289–298 (2006).Google Scholar
  13. Jansen, K., Scheffler, P.: Generalized coloring for tree-like graphs. Discret. Appl. Math. 75 (2), 135–155 (1997).MathSciNetCrossRefMATHGoogle Scholar
  14. Khayyat, Z., Lucia, W., Singh, M., Ouzzani, M., Papotti, P., Quiané-Ruiz, J., Tang, N., Kalnis, P.: Lightning fast and space efficient inequality joins. PVLDB. 8 (13), 2074–2085 (2015). http://www.vldb.org/pvldb/vol8/p2074-khayyat.pdf.Google Scholar
  15. Klug, A.: On conjunctive queries containing inequalities. J. ACM. 35 (1), 146–160 (1988).MathSciNetCrossRefMATHGoogle Scholar
  16. Kolaitis, P.G., Martin, D.L., Thakur, M.N.: On the Complexity of the Containment Problem for Conjunctive Queries with Built-In Predicates. PODS, 197–204 (1998).Google Scholar
  17. Koutris, P., Milo, T., Roy, S., Suciu, D.: Answering Conjunctive Queries with Inequalities. ICDT, 76–93 (2015).Google Scholar
  18. van der Meyden, R.: The complexity of querying indefinite data about linearly ordered domains. J. Comput. Syst. Sci. 54 (1), 113–135 (1997). doi:http://dx.doi.org/10.1006/jcss.1997.1455.MathSciNetCrossRefMATHGoogle Scholar
  19. Monien, B.: How to Find Long Paths Efficiently. Analysis and Design of Algorithms for Combinatorial Problems, North-Holland Mathematics Studies, vol. 109, pp. 239–254. North-Holland. Edited by: Ausiello, G., Lucertini, M. (1985).Google Scholar
  20. Ngo, H.Q., Porat, E., Ré, C., Rudra, A.: Worst-Case Optimal Join Algorithms: [Extended Abstract]. PODS, 37–48 (2012).Google Scholar
  21. Papadimitriou, C.H., Yannakakis, M.: On the Complexity of Database Queries. PODS, 12–19 (1997).Google Scholar
  22. Robertson, N., Seymour, P.: Graph minors. iii. planar tree-width. J. Comb. Theory B. 36 (1), 49–64 (1984).MathSciNetCrossRefMATHGoogle Scholar
  23. Veldhuizen, T.L.: Triejoin: a Simple, Worst-Case Optimal Join Algorithm. ICDT, 96–106 (2014).Google Scholar
  24. Yannakakis, M.: Algorithms for Acyclic Database Schemes. VLDB, 82–94 (1981).Google Scholar
  25. Yu, C., Ozsoyoglu, M.Z.: An Algorithm for Tree-Query Membership of a Distributed Query. COMPSAC, 306–312 (1979).Google Scholar
  26. Yuster, R., Zwick, U.: Finding even cycles even faster. SIAM J. Discrete Math. 10 (2), 209–222 (1997).MathSciNetCrossRefMATHGoogle Scholar

Copyright information

© Springer Science+Business Media New York 2016

Authors and Affiliations

  • Paraschos Koutris
    • 1
  • Tova Milo
    • 2
  • Sudeepa Roy
    • 1
  • Dan Suciu
    • 1
  1. 1.University of WashingtonSeattleUSA
  2. 2.Tel Aviv UniversityTel AvivIsrael

Personalised recommendations