Extending Scala with Database Query Capability

The integration of database and programming languages is dif- ficult due to the dierent data models and type systems prevalent in each field. We present a solution where the developer may express queries en- compassing program and database data. The notation used for queries is based on comprehensions, a declarative style that does not impose any specific execution strategy. In our approach, the type safety of language- integrated queries is analyzed at compile-time, followed by a translation that optimizes for database evaluation. We show the translation total and semantics preserving, and introduce a language-independent classifi- cation. According to this classification, our approach compares favorably with Microsoft's LINQ, today's best-known representative. We provide an implementation in terms of Scala compiler plugins, accepting two nota- tions for queries: LINQ and the native Scala syntax for comprehensions. The prototype relies on Ferry, a query language that already supports comprehensions yet targets SQL:1999. The reported techniques pave the way for further progress in bridging the programming and the database worlds.

[1]  Jens Teubner Pathfinder: XQuery Compilation Techniques for Relational Database Targets , 2007, BTW.

[2]  Adriaan Moors Type Constructor Polymorphism for Scala: Theory and Practice (Type constructor polymorfisme voor Scala: theorie en praktijk) ; Type Constructor Polymorphism for Scala: Theory and Practice , 2009 .

[3]  David Maier,et al.  Towards an effective calculus for object query languages , 1995, SIGMOD '95.

[4]  Eric E. Allen,et al.  Growing a Syntax , 2008 .

[5]  Norman W. Paton,et al.  MOVIE: An incremental maintenance system for materialized object views , 2003, Data Knowl. Eng..

[6]  Michael Isard,et al.  Distributed data-parallel computing using a high-level programming language , 2009, SIGMOD Conference.

[7]  Torsten Grust,et al.  XQuery Join Graph Isolation , 2008, ArXiv.

[8]  Gilles Dubochet On Embedding Domain-specific Languages with User-friendly Syntax , 2006 .

[9]  Philip A. Bernstein,et al.  Compiling mappings to bridge applications and databases , 2007, SIGMOD '07.

[10]  Torsten Grust,et al.  FERRY: database-supported program execution , 2009, SIGMOD Conference.

[11]  Philip W. Trinder,et al.  A processing framework for object comprehensions , 1997, Inf. Softw. Technol..

[12]  Limsoon Wong The functional guts of the Kleisli query system , 2000, ICFP '00.

[13]  David K. Gifford,et al.  Design Concepts in Programming Languages , 2008 .

[14]  Ezra Cooper,et al.  The Script-Writer's Dream: How to Write Great SQL in Your Own Language, and Be Sure It Will Succeed , 2009, DBPL.

[15]  Martin Odersky,et al.  Programming in Scala: A Comprehensive Step-by-Step Guide, 2nd Edition , 2010 .

[16]  James Noble,et al.  Efficient Object Querying for Java , 2006, ECOOP.

[17]  Anastasia Izmaylova,et al.  Compiling LINQ and a Scala subset into SQL : 1999 , 2009 .

[18]  Ronald Morrison,et al.  Orthogonal Persistence Revisited , 2009, ICOODB.

[19]  Ronald Morrison,et al.  Orthogonally persistent object systems , 1995, The VLDB Journal.

[20]  Tian Zhao,et al.  ScalaQL: Language-Integrated Database Queries for Scala , 2009, SLE.

[21]  Miguel Garcia,et al.  Compiler Plugins Can Handle Nested Languages: AST-Level Expansion of LINQ Queries for Java , 2009, ICOODB.

[22]  Nicolas Bruno,et al.  Towards Declarative Queries on Adaptive Data Structures , 2008, 2008 IEEE 24th International Conference on Data Engineering.

[23]  Andreas Rausch,et al.  Journal of Object Technology , 2002 .

[24]  Alexandra Poulovassilis,et al.  The Functional Approach to Data Management , 2004, Springer Berlin Heidelberg.

[25]  William R. Cook,et al.  Interprocedural query extraction for transparent persistence , 2008, OOPSLA.

[26]  Eric N. Hanson,et al.  Trigger Condition Testing and View Maintenance Using Optimized Discrimination Networks , 2002, IEEE Trans. Knowl. Data Eng..

[27]  Michael Stonebraker,et al.  Readings in Database Systems: Fourth Edition , 2005 .

[28]  Philip W. Trinder,et al.  A functional database , 1989 .

[29]  A. Clements A Comparison of Designs for Extensible and Extension-Oriented Compilers , 2008 .