Expressive power of SQL

  • Authors:
  • Leonid Libkin

  • Affiliations:
  • Department of Computer Science, University of Toronto, 6 King's College Road, Toronto, Ont., Canada M5S 3H5

  • Venue:
  • Theoretical Computer Science - Database theory
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

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 botmds for SQL as hard as some long-standing open problems in complexity theory.