Skip to main content

Capability-based localization of distributed and heterogeneous queries


One key aspect of data-centric applications is the manipulation of data stored in persistent repositories, which is moving fast from querying a centralized relational database to the ad-hoc combination of constellations of data sources. The extension of general purpose languages with query operations is increasingly popular, as a tool to improve reasoning and optimizing capabilities of interpreters and compilers. However, not much is being done to integrate and orchestrate different and separate sources of data. We present a data manipulation language that abstracts the nature and location of data-sources. We define its semantics and a type directed query localization mechanism to be used in development tools for heterogeneous environments to efficiently compile them into native queries. We introduce a localization procedure based on rewriting of query expressions that is confluent, terminating and provides the maximum mapping between site capabilities and the structure of the query. We provide formal type safety results that support the sound distribution of query fragments over remote sites. Our approach is also suitable for an interactive query construction environment by rich user interfaces that provide immediate feedback on data manipulation operations. This approach is currently the base for the data layer of a development platform for mobile and web applications.

Hide All
Benzaken, V., Castagna, G. & Frisch, A. (2003) CDuce: An XML-centric general-purpose language. In Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming (ICFP '03). New York, NY, USA: ACM, pp. 51–63.
Buneman, P., Libkin, L., Suciu, D., Tannen, V., & Wong, L. (1994) Comprehension syntax. ACM SIGMOD Rec. 23 (1), 8796.
Buneman, P., Naqvi, S., Tannen, V., & Wong, L. (1995) Principles of programming with complex objects and collection types. Theor. Comput. Sci. 149 (1), 348.
Cardelli, L. (1989) Typeful programming. In IFIP State of the Art Reports (Formal Description of Programming Concepts), Neuhold, Erich J. & Paul, M. (eds). New York, NY, USA: Springer-Verlag, pp. 431507.
Cardelli, L., Ghelli, G., & Gordon, A. D. (2002) Types for the ambient calculus. Inform. Comput. 177 (2), 160194.
Cheney, J., Lindley, S. & Wadler, P. (2013) A practical theory of language-integrated query. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP '13), New York, NY, USA: ACM, pp. 403–416.
Cheney, J., Lindley, S., & Wadler, P. (2014) Query shredding: Efficient relational evaluation of queries over nested multisets. In Proceedings of the 2014 ACM SIGMOD International Conference on Management of Data (SIGMOD '14). New York, NY, USA: ACM, pp. 1027–1038.
Chlipala, A. (2015) Ur/Web: A simple model for programming the web. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '15). New York, NY, USA: ACM, pp. 153–165.
Clark, J. & DeRose, S. J. (1999) Path Language (XPath) Version 1.0. Available at:
Colby, L. S. (1989) A recursive algebra and query optimization for nested relations. In Proceedings of the 1989 ACM SIGMOD International Conference on Management of Data (SIGMOD '89). New York, NY, USA: ACM, pp. 273–283.
Cooper, E. (2009) The Script-Writer's dream: How to write great SQL in your own language, and be sure it will succeed. In Proceedings of the 12th International Symposium on Database Programming Languages (DBPL '09). Berlin, Heidelberg: Springer-Verlag, pp. 36–51.
Cooper, E., Lindley, S., Wadler, P., & Yallop, J. (2007) Links: Web programming without tiers. In Proceedings of the 5th International Conference on Formal Methods for Components and Objects (FMCO '06). Berlin, Heidelberg: Springer-Verlag, pp. 266–296.
Davies, R., & Pfenning, F. (2001) A modal analysis of staged computation. J. ACM 48 (3), 555604.
Fu, Y., Ong, K. W., & Papakonstantinou, Y. (2013) Declarative ajax web applications through SQL++ on a unified application state. In Proceedings of the International Symposium on Database Programming Languages.
Grade, N., Ferrão, L., & Seco, J. C. (2013) Optimizing data queries over heterogeneous sources. In Proceedings of the 5th Simpósio de Informática, INForum.
Halevy, A., Rajaraman, A. & Ordille, J. (2006) Data integration: The teenage years. In Proceedings of the 32nd International Conference on Very Large Data Bases (VLDB '06). VLDB Endowment, pp. 9–16.
Lindley, S. & Cheney, J. (2012) Row-based effect types for database integration. In Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI '12). New York, NY, USA: ACM, pp. 91–102.
Murphy, T. VII, Crary, K. & Harper, R. (2008) Type-safe distributed programming with ML5. In Trustworthy Global Computing: Third Symposium, TGC 2007, Sophia-Antipolis, France, November 5-6, 2007, Revised Selected Papers, Barthe, G. & Fournet, C. (eds). Berlin, Heidelberg: Springer, pp. 108123.
Newman, M. H. A. (1942) On theories with a combinatorial definition of “equivalence”. Ann. Math. 43 (2), 223243.
OutSystems. (2016) Using aggregates – Fetch and display data from the database. Technical documentation. Available at:
Papakonstantinou, Y., Gupta, A. & Haas, L. (1998) Capabilities-based query rewriting in mediator systems. Distrib.Parallel Databases 6 (1), 73110.
Peyton Jones, S. & Wadler, P. (2007) Comprehensive comprehensions. In Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop (Haskell '07). ACM, pp. 61–72.
Robie, J. et al. (2014) XQuery 3.0: An XML query language. Available at:
Seco, J. C., Lourenço, H., & Ferreira, P. (2015) A common data manipulation language for nested data in heterogeneous environments. In Proceedings of the 15th Symposium on Database Programming Languages (DBPL '15), pp. 11–20.
Seco, J. C., Ferreira, P. & Lourenço, H. (2017) Capability-based Localization of Distributed and Heterogeneous Queries – Extended version with proofs. Technical Report, NOVA University of Lisbon. Available at:
Serrano, M., Gallesio, E. & Loitsch, F. (2006) Hop: A language for programming the web 2.0. In Companion to the 21th Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 975–985.
Silberschatz, A., Korth, H. & Sudarshan, S. (2006) Database Systems Concepts, 5 ed. New York, NY, USA: McGraw-Hill.
Taylor, R. (2010) Query Optimization for Distributed Database Systems. Master Thesis, University of Oxford, University of Oxford.
Vassalos, V. & Papakonstantinou, Y. (2000) Expressive capabilities description languages and query rewriting algorithms. J. Log. Program. 43 (1), 75122.
Wong, L. (2000) Kleisli, a functional query system. J. Funct. Program. 10 (1), 1956.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *


Altmetric attention score

Full text views

Total number of HTML views: 0
Total number of PDF views: 22 *
Loading metrics...

Abstract views

Total abstract views: 213 *
Loading metrics...

* Views captured on Cambridge Core between 12th December 2017 - 22nd July 2018. This data will be updated every 24 hours.

Capability-based localization of distributed and heterogeneous queries

Submit a response


No Discussions have been published for this article.


Reply to: Submit a response

Your details

Conflicting interests

Do you have any conflicting interests? *