Local properties of query languages
Expressiveness of database query languages remains the major motivation for research in finite model theory. However, most techniques in finite model theory are based on Ehrenfeucht-Fraisse games, whose application often involves a rather intricate argument. Furthermore, most tools apply to first-order logic and some of its extensions, but not to languages that resemble real query languages, like SQL.
In this paper we use locality to analyze expressiveness of query languages. A query is local if, to determine if a tuple belongs to the output, one only has to look at a certain predetermined portion of the input.
We study local properties of queries in a context that goes beyond the pure first-order case, and then apply the resulting tools to analyze expressive power of SQL-like languages. We first prove a general result describing outputs of local queries, that leads to many easy inexpressibility proofs. We then consider a closely related bounded degree property, which describes the outputs of queries on structures that locally look “simple,” and makes inexpressibility proofs particularly easy. We prove that every local query has this property. Since every relational calculus (first-order) query is local, these results can be viewed as “off-the-shelf” strategies for inexpressibility proofs, which are often easier to apply than the games. We also show that some generalizations of the bounded degree property that were conjectured to hold, fail for relational calculus.
We then prove that the language obtained from relational calculus by adding grouping and aggregates (essentially plain SQL), has the bounded degree property, thus solving an open problem. Consequently, first-order queries with Härtig and Rescher quantifiers have the bounded degree property. Finally, we apply our results to show that SQL and relational calculus are incapable of maintaining the transitive closure view even in the presence of certain kinds of auxiliary data.
KeywordsQuery Language Transitive Closure Expressive Power Auxiliary Data Aggregate Function
Unable to display preview. Download preview PDF.
- 1.S. Abiteboul, R. Hull, V. Vianu, Foundations of Databases, Addison Wesley, 1995.Google Scholar
- 2.S. Abiteboul, P. Kanellakis. Query languages for complex object databases. SIGACT News, 21(3):9–18, 1990.Google Scholar
- 3.M. Ajtai and R. Fagin. Reachability is harder for directed than for undirected graphs. Journal of Symbolic Logic, 55(1):113–150, March 1990.Google Scholar
- 4.J. Albert. Algebraic properties of bag data types. In VLDB'91, pages 211–219.Google Scholar
- 5.J. Barwise et al eds., Model-Theoretic Logics. Springer-Verlag, 1985.Google Scholar
- 6.P. Buneman, S. Naqvi, V. Tannen, L. Wong. Principles of programming with complex objects and collection types. Theoretical Computer Science, 149 (1995), 3–48.Google Scholar
- 7.S. Chaudhuri, M. Y. Vardi, Optimization of real conjunctive queries, In PODS'93.Google Scholar
- 8.M.P. Consens, A.O. Mendelzon, Low complexity aggregation in GraphLog and Datalog, Theoretical Computer Science 116 (1993), 95–116.Google Scholar
- 9.G. Dong, L. Libkin, L. Wong. On impossibility of decremental recomputation of recursive queries in relational calculus and SQL. In Database Progr. Lang. '95, Springer Electronic Workshops in Computing, 1996.Google Scholar
- 10.G. Dong, L. Libkin, L. Wong. Local properties of query languages, Tech. Memo, Bell Labs, 1995.Google Scholar
- 11.G. Dong and J. Su. Incremental and Decremental Evaluation of Transitive Closure by First-Order Queries. Information and Computation, 120(1):101–106, 1995.Google Scholar
- 12.G. Dong and J. Su. Space-bounded FOIES. In PODS'95, pages 139–150.Google Scholar
- 13.H.-D. Ebbinghaus and J. Flum. Finite Model Theory. Springer Verlag, 1995.Google Scholar
- 14.K. Etessami, Counting quantifiers, successor relations, and logarithmic space, in Conf. on Structure in Complexity Theory, 1995.Google Scholar
- 15.R. Fagin, L. Stockmeyer, M. Vardi, On monadic NP vs monadic co-NP, Information and Computation, 120 (1994), 78–92.Google Scholar
- 16.H. Gaifman, On local and non-local properties, in Logic Colloquium '81, North Holland, 1982.Google Scholar
- 17.T. Griffin, L. Libkin, Incremental maintenance of views with duplicates, In SIGMOD'95, pages 319–330.Google Scholar
- 18.S. Grumbach, T. Milo, Towards tractable algebras for bags, Journal of Computer and System Sciences, 52 (1996), 570–588.Google Scholar
- 19.S. Grumbach, L. Libkin, T. Milo and L. Wong. Query languages for bags: expressive power and complexity. SIGACT News, 27 (1996), 30–37.Google Scholar
- 20.S. Grumbach and C. Tollu. On the expressive power of counting. Theoretical Computer Science 149(1): 67–99, 1995.Google Scholar
- 21.A. Klug, Equivalence of relational algebra and relational calculus query languages having aggregate functions, Journal of the ACM 29, No. 3 (1982), 699–717.Google Scholar
- 22.L. Libkin, L. Wong, Some properties of query languages for bags, In DBPL'93, Springer, 1994.Google Scholar
- 23.L. Libkin, L. Wong, Query languages for bags and aggregate functions. JCSS, to appear. Extended abstract in PODS'94, pages 155–166.Google Scholar
- 24.L. Libkin, L. Wong, On representation and querying incomplete information in databases with bags, Information Processing Letters 56 (1995), 209–214.Google Scholar
- 25.G. Ozsoyoglu, Z. M. Ozsoyoglu, V. Matos, Extending relational algebra and relational calculus with set-valued attributes and aggregate functions, ACM Transactions on Database Systems 12, No. 4 (1987), 566–592.Google Scholar
- 26.J. Paredaens and D. Van Gucht. Converting nested relational algebra expressions into flat algebra expressions. ACM TODS, 17(1):65–93, March 1992.Google Scholar
- 27.S. Patnaik and N. Immerman. Dyn-FO: A parallel dynamic complexity class. In PODS'94, pages 210–221.Google Scholar
- 28.L. Wong, Normal forms and conservative properties for query languages over collection types, JCSS 52 (1996), 495–505.Google Scholar