Abstract

Language-integrated query based on comprehension syntax is a powerful technique for safe database programming, and provides a basis for advanced techniques such as query shredding or query flattening that allow efficient programming with complex nested collections. However, the foundations of these techniques are lacking: although SQL, the most widely-used database query language, supports heterogeneous queries that mix set and multiset semantics, these important capabilities are not supported by known correctness results or implementations that assume homogeneous collections. In this paper we study language-integrated query for a heterogeneous query language mathcal {NRC}_{lambda }( Set,Bag ) that combines set and multiset constructs. We show how to normalize and translate queries to SQL, and develop a novel approach to querying heterogeneous nested collections, based on the insight that “local” query subexpressions that calculate nested subcollections can be “lifted” to the top level analogously to lambda-lifting for local function definitions.

Highlights

  • Since the rise of relational databases as important software components in the 1980s, it has been widely appreciated that database programming is hard [13]

  • SQL has several other operations that can have either set or multiset semantics such as UNION and EXCEPT: how should they be handled?. To study this problem we introduced a core calculus N RCλ(Set, Bag) [42] in which there are two collection types, sets and multisets; duplicate elimination maps a multiset to a set with the same elements, and promotion maps a set to the least multiset with the same elements

  • We view finding correctness results for richer query languages as an important challenge for future work. Another parallel line of work started by Fegaras and Maier [15,14] considers heterogeneous query languages based on monoid comprehensions, with set, list, and bag collections as well as grouping, aggregation and ordering operations, in the setting of object-oriented databases, and forms the basis for complex object database systems such as λDB [16] and Apache MRQL [14]

Read more

Summary

Introduction

Since the rise of relational databases as important software components in the 1980s, it has been widely appreciated that database programming is hard [13]. An alternative approach, which has almost as long a history as the impedance mismatch problem itself, is to elevate queries in the host language from unchecked strings to a typed, domain-specific sublanguage, whose interactions with the rest of the program can be checked and which can be mapped to database queries safely while providing strong guarantees This approach is nowadays typically called language-integrated query following Microsoft’s successful LINQ extensions to .NET languages such as C# and F# [36,49]. Widely-used and practically important SQL features that mix set and multiset collections, such as duplicate elimination, are supported by some implementations, but without guarantees regarding correctness or reliability Such results have only been proved for special cases [7,8], typically for homogeneous queries operating on one uniform collection type. – Section 6 presents our results on translation of N RCλ(Set, Bag) queries that construct nested results to a bounded number of flat N RCG queries.

Overview
Background
A relational calculus of tabular functions
Semantics and translation to N RCλ(Set, Bag )
Delateralization
Query lifting and shredding
Reflecting shredded queries into N RCλ(Set, Bag )
The stitching function
Related work
Conclusions
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.