# A Framework for the Investigation of Aggregate Functions in Database Queries

## Abstract

In this paper we present a new approach for studying aggregations in the context of database query languages. Starting from a broad definition of aggregate function, we address our investigation from two different perspectives. We first propose a *declarative* notion of uniform aggregate function that refers to a family of scalar functions uniformly constructed over a vocabulary of basic operators by a bounded Turing Machine. This notion yields an effective tool to study the effect of the embedding of a *class* of built-in aggregate functions in a query language. All the aggregate functions most used in practice are included in this classification. We then present an *operational* notion of aggregate function, by considering a high-order folding constructor, based on structural recursion, devoted to compute numeric aggregations over complex values. We show that numeric folding over a given vocabulary is sometimes not able to compute, by itself, the whole class of uniform aggregate function over the same vocabulary. It turns out however that this limitation can be partially remedied by the restructuring capabilities of a query language.

## Keywords

Scalar Function Turing Machine Query Language Expressive Power Relational Algebra## Preview

Unable to display preview. Download preview PDF.

## References

- 1.S. Abiteboul and C. Beeri. The power of languages for the manipulation of complex values.
*The VLDB Journal*, 4(4):727–794, October 1995.CrossRefGoogle Scholar - 2.M. Benedikt and H. J. Keisler. Expressive power of unary counters. In
*International Conference on Data Base Theory*, Springer-Verlag, pages 291–305, 1997.Google Scholar - 3.M. Benedikt and L. Libkin. Languages for relational databases over interpreted structures. In
*Sixteenth ACM SIGACT SIGMOD SIGART Symp. on Principles of Database Systems*, pages 87–98, 1997.Google Scholar - 4.L. Blum, M. Shub, and S. Smale. On a theory of computation and complexity over the real numbers: NP-completeness, recursive functions and universal machines.
*Bull. Amer. Math. Soc.*, 21:1–46, 1989.zbMATHMathSciNetCrossRefGoogle Scholar - 5.P. Buneman, S. Naqvi, V. Tannen, and L. Wong. Principles of programming with complex objects and collection types.
*Theoretical Computer Science*, 149(1):3–48, 1995.zbMATHCrossRefMathSciNetGoogle Scholar - 6.L. S. Colby. A recursive algebra for nested relations.
*Information Systems*, 15(5):567–582, 1990.CrossRefMathSciNetGoogle Scholar - 7.M. P. Consens and A. O. Mendelzon. Low complexity aggregation in GraphLog and Datalog. In
*International Conference on Data Base Theory*, Springer-Verlag, pages 379–394, 1990.Google Scholar - 8.K. Etessami. Counting quantifiers, successor relations, and logarithmic space.
*Journal of Computer and Systems Science*, 54(3): 400–411, 1997.zbMATHCrossRefMathSciNetGoogle Scholar - 9.E. Grädel and Y. Gurevich. Metafinite model theory. In
*Logic and Computational Complexity*, Springer-Verlag, pages 313–366, 1995.Google Scholar - 10.E. Grädel and K. Meer. Descriptive complexity theory over the real numbers. In
*Twenty-Seventh Annual ACM Symposium on Theory of Computing*, pages 315–324, 1995.Google Scholar - 11.S. Grumbach and C. Tollu. On the expressive power of counting.
*Theoretical Computer Science*, 149(1):67–99, 1995.zbMATHCrossRefMathSciNetGoogle Scholar - 12.R.M. Karp and V. Ramachandran. Parallel algorithms for shared-memory machines. In J. van Leeuwen, editor,
*Handbook of Theoretical Computer Science*, volume A, pages 869–941. Elsevier Science Publishers (North-Holland), Amsterdam, 1990.Google Scholar - 13.A. Klug. Equivalence of relational algebra and relational calculus query languages having aggregate functions.
*Journal of the ACM*, 29(3):699–717, 1982.zbMATHCrossRefMathSciNetGoogle Scholar - 14.L. Libkin and L. Wong. New techniques for studying set languages, bag languages and aggregate functions. In
*Thirteenth ACM SIGACT SIGMOD SIGART Symp. on Principles of Database Systems*, pages 155–166, 1994.Google Scholar - 15.L. Libkin and L. Wong. Query languages for bags and aggregate functions.
*Journal of Computer and System Sciences*, 1997. To appear.Google Scholar - 16.G. Özsoyoglu, Z. M. Özsoyoglu, V. Matos. Extending relational algebra and relational calculus with set-valued attributes and aggregate functions.
*ACM Transactions on Database Systems*, 12(4):566–592, 1987.CrossRefGoogle Scholar - 17.A. Poulovassilis and C. Small. Algebraic query optimisation for database programming languages.
*The VLDB Journal*, 5(2):119–132, April 1996.CrossRefGoogle Scholar - 18.W. L. Ruzzo. On uniform circuit complexity.
*Journal of Computer and Systems Science*, 22: 365–383, 1981.zbMATHCrossRefMathSciNetGoogle Scholar - 19.H. Schek and M. H. Scholl. The relational model with relation-valued attributes.
*Information Systems*, 11(2):137–147, 1986.zbMATHCrossRefGoogle Scholar - 20.S. J. Thomas and P. C. Fisher. Nested relational structures. In
*Advances in Computing Research: the theory of database*, JAI Press, 1986.Google Scholar