The relational calculus (RC) is a concise, declarative query language. However, existing RC query evaluation approaches are inefficient and often deviate from established algorithms based on finite tables used in database management systems. We devise a new translation of an arbitrary RC query into two safe-range queries, for which the finiteness of the query's evaluation result is guaranteed. Assuming an infinite domain, the two queries have the following meaning: The first is closed and characterizes the original query's relative safety, i.e., whether given a fixed database, the original query evaluates to a finite relation. The second safe-range query is equivalent to the original query, if the latter is relatively safe. We compose our translation with other, more standard ones to ultimately obtain two SQL queries. This allows us to use standard database management systems to evaluate arbitrary RC queries. We show that our translation improves the time complexity over existing approaches, which we also empirically confirm in both realistic and synthetic experiments.
翻译:关系演算(RC)是一种简洁且声明性的查询语言。然而,现有的RC查询评估方法效率低下,且常常偏离数据库管理系统中基于有限表的成熟算法。我们设计了一种新方法,将任意RC查询转换为两个安全范围查询,从而保证查询评估结果的有限性。在无限域假设下,这两个查询的含义如下:第一个是封闭的,表征原始查询的相对安全性,即给定固定数据库时,原始查询是否评估为有限关系。第二个安全范围查询等价于原始查询(若后者相对安全)。我们将此翻译与其他更标准的方法相结合,最终得到两个SQL查询,从而能够利用标准数据库管理系统评估任意RC查询。我们证明,与现有方法相比,我们的翻译提升了时间复杂度,并在真实与合成实验中实证确认了这一改进。