Skip to main content

Expressive Power of SQL

  • Conference paper
  • First Online:
Database Theory — ICDT 2001 (ICDT 2001)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1973))

Included in the following conference series:

Abstract

It is a folk result in database theory that SQL cannot express recursive queries such as reachability; in fact, a new construct was added to SQL3 to overcome this limitation. However, the evidence for this claim is usually given in the form of a reference to a proof that relational algebra cannot express such queries. SQL, on the other hand, in all its implementations has three features that fundamentally distinguish it from relational algebra: namely, grouping, arithmetic operations, and aggregation.

In the past few years, most questions about the additional power provided by these features have been answered. This paper surveys those results, and presents new simple and self-contained proofs of the main results on the expressive power of SQL. Somewhat surprisingly, tiny differences in the language definition affect the results in a dramatic way: under some very natural assumptions, it can be proved that SQL cannot define recursive queries, no matter what aggregate functions and arithmetic operations are allowed. But relaxing these assumptions just a tiny bit makes the problem of proving expressivity bounds for SQL as hard as some long-standing open problems in complexity theory.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. S. Abiteboul, R. Hull and V. Vianu. Foundations of Databases, Addison Wesley, 1995.

    Google Scholar 

  2. A. V. Aho and J. D. Ullman. Universality of data retrieval languages. In POPL’79, pages 110–120.

    Google Scholar 

  3. D.M. Barrington, N. Immerman, H. Straubing. On uniformity within NC 1. JCSS, 41:274–306, 1990.

    MATH  MathSciNet  Google Scholar 

  4. P. Buneman, S. Naqvi, V. Tannen, L. Wong. Principles of programming with complex objects and collection types. TCS, 149 (1995), 3–48.

    Article  MATH  MathSciNet  Google Scholar 

  5. J. Celko. SQL for Smarties: Advanced SQL Programming. Morgan Kaufmann, 2000.

    Google Scholar 

  6. M. Consens and A. Mendelzon. Low complexity aggregation in GraphLog and Datalog, TCS 116 (1993), 95–116. Extended abstract in ICDT’90.

    Article  MATH  MathSciNet  Google Scholar 

  7. C. J. Date and H. Darwen. A Guide to the SQL Standard. Addison Wesley, 1997.

    Google Scholar 

  8. G. Dong, L. Libkin and L. Wong. Local properties of query languages. TCS 239 (2000), 277–308. Extended abstract in ICDT’97.

    Article  MATH  MathSciNet  Google Scholar 

  9. M. Grohe and T. Schwentick. Locality of order-invariant first-order formulas. ACM TOCL, 1 (2000), 112–130.

    Article  MathSciNet  Google Scholar 

  10. K. Etessami. Counting quantifiers, successor relations, and logarithmic space, JCSS, 54 (1997), 400–411.

    MATH  MathSciNet  Google Scholar 

  11. R. Fagin, L. Stockmeyer and M. Vardi, On monadic NP vs monadic co-NP, Information and Computation, 120 (1995), 78–92.

    Article  MATH  MathSciNet  Google Scholar 

  12. S. Finkelstein, N. Mattos, I.S. Mumick, and H. Pirahesh. Expressing recursive queries in SQL. ANSI Document X3H2-96-075r1, 1996.

    Google Scholar 

  13. H. Gaifman. On local and non-local properties, Proceedings of the Herbrand Symposium, Logic Colloquium’ 81, North Holland, 1982.

    Google Scholar 

  14. E. Grädel and Y. Gurevich. Metafinite model theory. Information and Computation 140 (1998), 26–81.

    Article  MATH  MathSciNet  Google Scholar 

  15. W. Hanf. Model-theoretic methods in the study of elementary logic. In J.W. Addison et al, eds, The Theory of Models, North Holland, 1965, pages 132–145.

    Google Scholar 

  16. L. Hella. Logical hierarchies in PTIME. Information and Computation, 129 (1996), 1–19.

    Article  MATH  MathSciNet  Google Scholar 

  17. L. Hella, L. Libkin and J. Nurmonen. Notions of locality and their logical characterizations over finite models. J. Symb. Logic, 64 (1999), 1751–1773.

    Article  MATH  MathSciNet  Google Scholar 

  18. L. Hella, L. Libkin, J. Nurmonen and L. Wong. Logics with aggregate operators. In LICS’99, pages 35–44.

    Google Scholar 

  19. N. Immerman. Descriptive Complexity. Springer Verlag, 1998.

    Google Scholar 

  20. A. Klug. Equivalence of relational algebra and relational calculus query languages having aggregate functions. J. ACM 29 (1982), 699–717.

    Article  MATH  Google Scholar 

  21. L. Libkin. On the forms of locality over finite models. In LICS’97, pages 204–215.

    Google Scholar 

  22. L. Libkin. Logics with counting and local properties. ACM TOCL, 1 (2000), 33–59. Extended abstract in LICS’98.

    Article  MathSciNet  Google Scholar 

  23. L. Libkin, L. Wong. Query languages for bags and aggregate functions. JCSS 55 (1997), 241–272. Extended abstract in PODS’94.

    MATH  MathSciNet  Google Scholar 

  24. L. Libkin and L. Wong. On the power of aggregation in relational query languages. In DBPL’97, pages 260–280.

    Google Scholar 

  25. P. O’Neil. Database: Principles, Programming, Performance. Morgan Kaufmann, 1994.

    Google Scholar 

  26. I. Parberry and G. Schnitger. Parallel computation and threshold functions. JCSS 36 (1988), 278–302.

    MATH  MathSciNet  Google Scholar 

  27. A. Razborov and S. Rudich. Natural proofs. JCSS 55 (1997), 24–35.

    MATH  MathSciNet  Google Scholar 

  28. P. Wadler. Comprehending monads. Mathematical Structures in Computer Science 2 (1992), 461–493.

    Article  MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2001 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Libkin, L. (2001). Expressive Power of SQL. In: Van den Bussche, J., Vianu, V. (eds) Database Theory — ICDT 2001. ICDT 2001. Lecture Notes in Computer Science, vol 1973. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44503-X_1

Download citation

  • DOI: https://doi.org/10.1007/3-540-44503-X_1

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-41456-8

  • Online ISBN: 978-3-540-44503-6

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics