Master Thesis

Language-Integrated Queries in Scala

Last Update6th Jan. 2010
Licence /*******************************************************************************
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Author:
* Kaichuan Wen, http://www.wen-k.com/
*******************************************************************************/
AbstractThe integration of modern programming language and functional database query languages brings in new innovation in data access mechanism. On the one hand, programming languages combine object-orientation paradigm and functional programming style, benefiting from the joint advantage and convenience of both. On the other hand, functional database query languages like LINQ provide a manner of language-integrated query, which enables deep participation of the host-language in query processing.

This Master Thesis investigates and implements this integration. It goes one step further by achieving another integration of object model and relational model. This O/R mapping is implemented through the translation into an intermediate language. The resulting prototype enables a scenario where queries in functional query language(LINQ), embedded in programming language(Scala), are triggered on object model(EMF), which has been persisted in relational model(DBMS). In this scenario, each party acts out its own expertise respectively.

In this thesis it is also argued why (a) the persistent representation(in the RDBMS) is isomorphic to its programming language counterpart(in main memory); and (b) similarly for queries at the programming and query language level.

DownloadFull Text (PDF)   |   Prototype (ZIP)   |   Defense Presentation (PDF)
Instruction Entry Class: orm.Main
To run LINQ query:
  1. Import projects "ORM" and "CSTLinq" in Eclipse
  2. In "Build path" of project ORM, import project CSTLinq
  3. Install MySQL 5.1 or later
  4. Setup a database (default name is "mt", other name can be specified in method getConn in jdbc.jdbc.scala)
  5. Create a user with name "wen" and password "wen"(other identity can be specified in method getConn in jdbc.jdbc.scala), and grand him the privilege for the database created in step (4)
  6. create or adjust the existed ecore model, and specify it as input in method testPersist in orm.Main.scala (after every update of ecore model, the corresponding genmodel should be reloaded, and model code should be generated again using the genmodel)
  7. create object population underlying this EMF model, like in method testPersist in orm.Main.scala (evetual methods can be defined in ferry.Trans.scala to instantiate objects, like genEmp)
  8. provide LINQ query in method trans in method trans in LINQ.LINQTranslator.scala, according to the above EMF model and object population
  9. resulted Ferry expressions can be found in console, along with origin LINQ query, query in SQO, query in functional syntax, SQL statements for persistence
Happy Querying!

Useful LinksThe Scala Compiler Corner
TOP    BACK