The Script-Writer’s Dream: How to Write Great SQL in Your Own Language, and Be Sure It Will Succeed

  • Ezra Cooper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5708)

Abstract

We show how to translate expressions in a higher-order programming language into SQL queries. Somewhat surprisingly, we show that any suitable expression translates to a single SQL query, where the suitability is determined by a type-and-effect check. Thus, unlike in Hollywood where a script-writer can never be sure a movie sequel will be popular, we show how to be sure that your SQL—written in your own language—will succeed (in being translated).

Keywords

Normal Form Query Language Relational Algebra Source Language Functional Programming Language 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Copeland, G., Maier, D.: Making smalltalk a database system. SIGMOD Rec. 14(2), 316–325 (1984)CrossRefGoogle Scholar
  2. 2.
    Wong, L.: Kleisli, a functional query system. J. Functional Programming 10(1), 19–56 (2000)MathSciNetCrossRefGoogle Scholar
  3. 3.
    Microsoft Corporation: The LINQ project: .NET language integrated query. White paper (September 2005)Google Scholar
  4. 4.
    Cooper, E., Lindley, S., Wadler, P., Yallop, J.: Links: Web programming without tiers. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2006. LNCS, vol. 4709, pp. 266–296. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  5. 5.
    Grust, T., Mayr, M., Rittinger, J., Schreiber, T.: Ferry: Database-supported program execution. In: SIGMOD 2009 (June 2009)Google Scholar
  6. 6.
    Wong, L.: Normal forms and conservative extension properties for query languages over collection types. J. Comput. Syst. Sci. 52(3), 495–505 (1996)MathSciNetCrossRefMATHGoogle Scholar
  7. 7.
    Fegaras, L.: Query unnesting in object-oriented databases. In: SIGMOD 1998, pp. 49–60. ACM, New York (1998)Google Scholar
  8. 8.
    Talpin, J., Jouvelot, P.: The type and effect discipline. Information and Computation, 162–173 (1992)Google Scholar
  9. 9.
    Cooper, E.: The script-writer’s dream: How to write great SQL in your own language, and be sure it will succeed (tech report). Technical Report EDI-INF-RR-1327, University of Edinburgh (May 2009)Google Scholar
  10. 10.
    Lindley, S., Stark, I.: Reducibility and ⊤ ⊤-lifting for computation types. In: Urzyczyn, P. (ed.) TLCA 2005. LNCS, vol. 3461, pp. 262–277. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  11. 11.
    Thomas, S.J., Fischer, P.C.: Nested relational structures. Advances in Computing Research 3, 269–307 (1986)Google Scholar
  12. 12.
    Paredaens, J., Van Gucht, D.: Possibilities and limitations of using flat operators in nested algebra expressions. In: PODS 1988, pp. 29–38. ACM, New York (1988)Google Scholar
  13. 13.
    Suciu, D.: Fixpoints and bounded fixpoints for complex objects. In: DBPL 1993, pp. 263–281 (1993)Google Scholar
  14. 14.
    Suciu, D., Wong, L.: On two forms of structural recursion. In: Y. Vardi, M., Gottlob, G. (eds.) ICDT 1995. LNCS, vol. 893, pp. 111–124. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  15. 15.
    Van den Bussche, J.: Simulation of the nested relational algebra by the flat relational algebra, with an application to the complexity of evaluating powerset algebra expressions. Theoretical Computer Science 254(1-2), 363–377 (2001)MathSciNetCrossRefMATHGoogle Scholar
  16. 16.
    Atkinson, M.P., Buneman, O.P.: Types and persistence in database programming languages. ACM Comput. Surv. 19(2), 105–170 (1987)CrossRefGoogle Scholar
  17. 17.
    Trinder, P.: Comprehensions, a query notation for DBPLs. In: DBPL 1991, San Francisco, CA, USA (1992)Google Scholar
  18. 18.
    Breazu-Tannen, V., Buneman, P., Wong, L.: Naturally embedded query languages. In: Hull, R., Biskup, J. (eds.) ICDT 1992. LNCS, vol. 646, pp. 140–154. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  19. 19.
    Buneman, P., Libkin, L., Suciu, D., Tannen, V., Wong, L.: Comprehension syntax. SIGMOD Record 23, 87–96 (1994)CrossRefGoogle Scholar
  20. 20.
    Grust, T., Scholl, M.H.: How to comprehend queries functionally. J. Intell. Inf. Syst. 12(2-3), 191–218 (1999)CrossRefGoogle Scholar
  21. 21.
    Grust, T.: Monad comprehensions, a versatile representation for queries. In: The Functional Approach to Data Management, pp. 288–311. Springer, Heidelberg (2003)Google Scholar
  22. 22.
    Wiedermann, B., Cook, W.R.: Extracting queries by static analysis of transparent persistence. In: POPL 2007 (2007)Google Scholar
  23. 23.
    Buneman, P., Davidson, S.B., Hart, K., Overton, C., Wong, L.: A data transformation system for biological data sources. In: VLDB 1995, pp. 158–169 (1995)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Ezra Cooper
    • 1
  1. 1.University of EdinburghUK

Personalised recommendations