A calculus for collections and aggregates

  • Kazem Lellahi
  • Val Tannen
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1290)


We present a calculus that should play for database query languages the same role that the lambda calculus plays for functional programming. For the semantic foundations of the calculus we introduce a new concept: monads enriched with algebraic structure. We model collection types through enriched monads and aggregate operations through enriched monad algebras. The calculus derives program equivalences that underlie a good number of the optimizations used in query languages.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [Bac88]
    R. C. Backhouse. An exploration of the Bird-Meertens formalism. Technical Report CS 8810, Groningen University, The Netherlands, 1988.Google Scholar
  2. [BBW92]
    Val Breazu-Tannen, Peter Buneman, and Limsoon Wong. Naturally embedded query languages. In J. Biskup and R. Hull, editors, LNCS 646: Proceedings of 4th International Conference on Database Theory, Berlin, Germany, October, 1992, pages 140–154. Springer-Verlag, October 1992.Google Scholar
  3. [BNTW95]
    Peter Buneman, Shamim Naqvi, Val Tannen, and Limsoon Wong. Principles of programming with complex objects and collection types. Theoretical Computer Science, 149(1):3–48, September 1995.MATHMathSciNetCrossRefGoogle Scholar
  4. [Bor94]
    F. Borceux. Handbook of categorical algebra, Vol.2. Cambridge University Press, 1994.Google Scholar
  5. [BTS91]
    V. Breazu-Tannen and R. Subrahmanyam. Logical and computational aspects of programming with Sets/Bags/Lists. In LNCS 510: Proceedings of 18th International Colloquium on Automata, Languages, and Programming, Madrid, Spain, July 1991, pages 60–75. Springer Verlag, 1991.Google Scholar
  6. [BW85]
    Michael Barr and Charles Wells. Toposes, Triples, and Theories. Springer-Verlag, New York, 1985.MATHGoogle Scholar
  7. [Cat96]
    R. G. G. Cattell, editor. The Object Database Standard: ODMG-93. Morgan Kaufmann, San Mateo, California, 1996.MATHGoogle Scholar
  8. [Di 96]
    R. Di Cosmo. On the power of simple diagrams. In LNCS 1103: Rewriting Techniques and Applications, New Brunswick, NJ, July 1996, Berlin, July 1996. Springer-Verlag.Google Scholar
  9. [EM65]
    S. Eilenberg and J. C. Moore. Adjoint functors and triples. Illinois Journal of Mathematics, 9:381–398, 1965.MATHMathSciNetGoogle Scholar
  10. [Fil96]
    A. Filinski. Controlling effects. PhD thesis, School of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213, May 1996. Available as CMU Technical Report CMU-CS-96-119.Google Scholar
  11. [FM95]
    Leonidas Fegaras and David Maier. Towards an effective calculus for object query languages. In Proceedings of ACM SIGMOD International Conference on Management of Data, pages 47–58, San Jose, California, May 1995.Google Scholar
  12. [GLP93]
    A. Gill, J. Launchbury, and S. Peyton Jones. A short cut to deforestation. In Proceedings of Conference on Functional Programming Languages and Computer Architecture, pages 223–232, 1993.Google Scholar
  13. [Hoo94]
    P. Hoogendijk. Relational programming laws in the Boom hierarchy of types. Technical report, Eindhoven University of Technology, The Netherlands, 1994.Google Scholar
  14. [Kle65]
    H. Kleisli. Every standard construction is induced by a pair of adjoint functors. Proceedings of the American Mathematical Society, 16:544–546, 1965.MATHMathSciNetCrossRefGoogle Scholar
  15. [Lel94a]
    K. Lellahi. Towards a characterization of bulk types. Technical Report 94-01, Université Paris 13, LIPN, 1994.Google Scholar
  16. [Lel94b]
    K. Lellahi. Type de collection et monades. In Actes des Journées Cateégories, Algèbres, Esquisses et neo-esquisses, Caen, 1994.Google Scholar
  17. [LS86]
    J. Lambek and P. J. Scott. Introduction to Higher Order Categorical Logic, volume 7 of Cambridge Studies in Advanced Mathematics. Cambridge University Press, London, 1986.Google Scholar
  18. [LS95]
    J. Launchbury and T. Sheard. Warm fusion: deriving build-catas from recursive definitions. In Proceedings of Conference on Functional Programming Languages and Computer Architecture, pages 314–323, 1995.Google Scholar
  19. [LW94a]
    Leonid Libkin and Limsoon Wong. Aggregate functions, conservative extension, and linear orders. In Catriel Beeri, Atsushi Ohori, and Dennis E. Shasha, editors, Proceedings of DBPL-4; New York, August 1993, pages 282–294. Springer-Verlag, January 1994.Google Scholar
  20. [LW94b]
    Leonid Libkin and Limsoon Wong. Some properties of query languages for bags. In Catriel Beeri, Atsushi Ohori, and Dennis E. Shasha, editors, Proceedings of DBPL-4, New York, August 1993, pages 97–114. Springer-Verlag, January 1994.Google Scholar
  21. [Mac71]
    S. MacLane. Categories for the Working Mathematician. Springer-Verlag, Berlin, 1971.Google Scholar
  22. [Man76]
    Ernest G. Manes.Algebraic Theories, volume 26 of Graduate Texts in Mathematics. Springer-Verlag, Berlin, 1976.Google Scholar
  23. [MFP91]
    Erik Meijer, Maartens Fokkinga, and Ross Paterson. Functional programming with bananas, lenses, envelopes, and barbed wires. In J. Hughes, editor, LNCS 523. 5th ACM Conference on Functional Languages and Computer Architecture, pages 124–144. Springer-Verlag, August 1991.Google Scholar
  24. [Mog91]
    Eugenio Moggi. Notions of computation and monads. Information and Computation, 93:55–92, 1991.MATHMathSciNetCrossRefGoogle Scholar
  25. [Mul92]
    P. Mulry. Monads and algebras in the semantics of partial data types. Theoretical Computer Science, 99:141–155, 1992.MATHMathSciNetCrossRefGoogle Scholar
  26. [Mul97]
    P. Mulry, May 1997. Private communication.Google Scholar
  27. [SBT94]
    Dan Suciu and Val Breazu-Tannen. A query language for NC. In Proceedings of 13th ACM Symposium on Principles of Database Systems, pages 167–178, Minneapolis, Minnesota, May 1994. See also UPenn Technical Report MS-CIS-94-05.Google Scholar
  28. [Tri91]
    P. W. Trinder. Comprehensions, a query notation for DBPLs. In Proceedings of 3rd International Workshop on Database Programming Languages, Nahplion, Greece, pages 49–62. Morgan Kaufmann, August 1991.Google Scholar
  29. [Wad92]
    Philip Wadler. Comprehending monads. Mathematical Structures in Computer Science, 2:461–493, 1992.MATHMathSciNetCrossRefGoogle Scholar
  30. [Won93]
    Limsoon Wong. Normal forms and conservative properties for query languages over collection types. In Proceedings of 12th ACM Symposium on Principles of Database Systems, pages 26–36, Washington, D. C., May 1993. See also UPenn Technical Report MS-CIS-92-59.Google Scholar
  31. [Won94]
    Limsoon Wong. Querying Nested Collections. PhD thesis, Department of Computer and Information Science, University of Pennsylvania, Philadelphia, PA 19104, August 1994. Available as University of Pennsylvania IRCS Report 94-09.Google Scholar
  32. [WT91]
    David A. Watt and Phil Trinder. Towards a theory of bulk types. Fide Technical Report 91126, Glasgow University, Glasgow G12 8QQ, Scotland, July 1991.Google Scholar

Copyright information

© Springer-Verlag 1997

Authors and Affiliations

  • Kazem Lellahi
    • 1
  • Val Tannen
    • 2
  1. 1.LIPN, URA 1507 du CNRSUniversité de Paris 13, Institut GaliléeVilletaneuseFrance
  2. 2.CIS DepartmentUniversity of PennsylvaniaPhiladelphiaUSA

Personalised recommendations