关系学和SQL中递归查询的递减重计算的不可能性

Guozhu Dong, L. Libkin, L. Wong
{"title":"关系学和SQL中递归查询的递减重计算的不可能性","authors":"Guozhu Dong, L. Libkin, L. Wong","doi":"10.14236/EWIC/DBPL1995.10","DOIUrl":null,"url":null,"abstract":"We study the problem of maintaining recursively-de ned views, such as the transitive closure of a relation, in traditional relational languages that do not have recursion mechanisms. In particular, we show that the transitive closure cannot be maintained in relational calculus under deletion of edges. We use new proof techniques to show this result. These proof techniques generalize to other languages, for example, to the language for nested relations that also contains a number of aggregate functions. Such a language is considered in this paper as a theoretical reconstruction of SQL. Our proof techniques also generalize to other recursive queries. Consequently, we show that a number of recursive queries cannot be maintained in an SQL-like language. We show that this continues to be true in the presence of certain auxiliary relations. We also relate the complexity of updating transitive closure to that of updating the samegeneration query and show that the latter is strictly harder than the former. Then we extend this result to that of updating queries based on context-free sets. 1 Problem Statement and Summary It is well known that relational calculus (equivalently, rst-order logic) cannot express recursive queries such as transitive closure [1]. However, in a real database system, it is reasonable to store both the relation and its transitive closure and update the latter whenever edges are added to or removed from the former. Doing this is known under the name of view maintenance. In this paper we consider the problem of whether the above update problem for maintaining transitive closure and other recursive queries can be accomplished using relational calculus or using its practical SQL-like extensions. We also compare the complexity of maintaining transitive closure against the complexity of maintaining \\same generation\" and context-free chain queries. In this paper, we use the letter R to denote a binary relation, and R to denote its transitive closure. It can be proved [6, 2] that given R, R, and a new edge (x; y) to be added to R, the transitive closure R +(x;y) of R [ f(x; y)g can be expressed in rst-order logic and thus in relational calculus. In particular, for all u and v, R +(x;y) (u; v) i R(u; v), or R(u; x) and y = v, or u = x and R(y; v), or R(u; x) and R(y; v). Thus transitive closure can be incrementally maintained in a relational database. The problem of updating the transitive closure after an edge has been removed is more di cult. The best positive solution so far is that of Dong and Su [5]. They proved that if R is acyclic, then the transitive closure R (x;y) of R with the edge (x; y) removed can be de ned in rst-order logic in terms of R, R , and (x; y). Thus transitive closure can be decrementally maintained in a relational database provided the relation involved is acyclic. But this is not satisfactory because acyclicity cannot be tested in relational calculus [10]. Database Programming Languages, 1995 1 On Impossibility of Decremental Recomputation of Recursive Queries in Relational Calculus and SQL Another solution is that of Immerman and Patnaik [14]. They proved that transitive closure of undirected graphs can always be maintained, provided some auxiliary ternary relations can be used. Dong and Su [7] strengthened this result further by showing that transitive closure of undirected graphs can be maintained using only auxiliary binary relations. They also showed that it cannot be done using only auxiliary unary relations. In Section 2, we prove that transitive closure cannot be decrementally maintained in a relational database in general. That is, R (x;y) cannot be expressed in relational calculus in terms of R, R , and (x; y) when R is a directed graph that is not necessarily acyclic. We also consider the problem of maintaining transitive closure in a context where some auxiliary relations are available. Dong and Su [7] also obtained results that are similar to ours. However, the proof techniques involved are very di erent. Most importantly, their proof technique is only applicable to the particular case of maintaining transitive closure in relational calculus. Ours is much simpler and can be generalized to more expressive languages and other recursive queries. In particular, instead of transitive closure, any query complete for DLOGSPACE can be used. In Section 3 we show that our technique extends naturally to prove that transitive closure cannot be decrementally maintained using query languages having the power of SQL. That is, we show that the availability of arithmetic operations and GROUP-BY does not help at all. We also extend this result in the presence of simple auxiliary relations. In addition, we exhibit a query that illustrates the additional power of using an SQL-like language incrementally. This query, which is inexpressible in SQL, is expressible incrementally in SQL with certain auxiliary relations but is not expressible incrementally in rst-order logic with the same auxiliary relations. In Section 4, we look at the complexity of maintaining transitive closure against the complexity of maintaining other queries. We prove that it is strictly more di cult to maintain the \\same generation\" query than to maintain transitive closure. We are also able to generalize this result and show that maintaining context-free chain queries (in a certain sense to be de ned) is at least as hard as maintaining transitive closure. In Section 5 we extend our basic technique to show that the same-generation query cannot be maintained (incrementally or decrementally) in SQL-like languages. 2 Recomputation of Recursive Queries in Relational Calculus The purpose of this section is to show that the transitive closure of a relation cannot be decrementally maintained in relational calculus or rst-order logic. That is, Theorem 2.1 There is no relational calculus expression that de nes the transitive closure R (x;y) of R f(x; y)g in terms of a binary relation R, its transitive closure R, and an edge (x; y). We introduce a new proof technique that is di erent from [7]. In particular, our technique does not rely on games and can be readily extended to other queries and languages. For example, we will show that the analog of Theorem 2.1 holds for a language having the expressive power of SQL.","PeriodicalId":211031,"journal":{"name":"International Workshop/Symposium on Database Programming Languages","volume":"18 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"1995-09-06","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"26","resultStr":"{\"title\":\"On Impossibility of Decremental Recomputation of Recursive Queries in Relational Calculus and SQL\",\"authors\":\"Guozhu Dong, L. Libkin, L. Wong\",\"doi\":\"10.14236/EWIC/DBPL1995.10\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"We study the problem of maintaining recursively-de ned views, such as the transitive closure of a relation, in traditional relational languages that do not have recursion mechanisms. In particular, we show that the transitive closure cannot be maintained in relational calculus under deletion of edges. We use new proof techniques to show this result. These proof techniques generalize to other languages, for example, to the language for nested relations that also contains a number of aggregate functions. Such a language is considered in this paper as a theoretical reconstruction of SQL. Our proof techniques also generalize to other recursive queries. Consequently, we show that a number of recursive queries cannot be maintained in an SQL-like language. We show that this continues to be true in the presence of certain auxiliary relations. We also relate the complexity of updating transitive closure to that of updating the samegeneration query and show that the latter is strictly harder than the former. Then we extend this result to that of updating queries based on context-free sets. 1 Problem Statement and Summary It is well known that relational calculus (equivalently, rst-order logic) cannot express recursive queries such as transitive closure [1]. However, in a real database system, it is reasonable to store both the relation and its transitive closure and update the latter whenever edges are added to or removed from the former. Doing this is known under the name of view maintenance. In this paper we consider the problem of whether the above update problem for maintaining transitive closure and other recursive queries can be accomplished using relational calculus or using its practical SQL-like extensions. We also compare the complexity of maintaining transitive closure against the complexity of maintaining \\\\same generation\\\" and context-free chain queries. In this paper, we use the letter R to denote a binary relation, and R to denote its transitive closure. It can be proved [6, 2] that given R, R, and a new edge (x; y) to be added to R, the transitive closure R +(x;y) of R [ f(x; y)g can be expressed in rst-order logic and thus in relational calculus. In particular, for all u and v, R +(x;y) (u; v) i R(u; v), or R(u; x) and y = v, or u = x and R(y; v), or R(u; x) and R(y; v). Thus transitive closure can be incrementally maintained in a relational database. The problem of updating the transitive closure after an edge has been removed is more di cult. The best positive solution so far is that of Dong and Su [5]. They proved that if R is acyclic, then the transitive closure R (x;y) of R with the edge (x; y) removed can be de ned in rst-order logic in terms of R, R , and (x; y). Thus transitive closure can be decrementally maintained in a relational database provided the relation involved is acyclic. But this is not satisfactory because acyclicity cannot be tested in relational calculus [10]. Database Programming Languages, 1995 1 On Impossibility of Decremental Recomputation of Recursive Queries in Relational Calculus and SQL Another solution is that of Immerman and Patnaik [14]. They proved that transitive closure of undirected graphs can always be maintained, provided some auxiliary ternary relations can be used. Dong and Su [7] strengthened this result further by showing that transitive closure of undirected graphs can be maintained using only auxiliary binary relations. They also showed that it cannot be done using only auxiliary unary relations. In Section 2, we prove that transitive closure cannot be decrementally maintained in a relational database in general. That is, R (x;y) cannot be expressed in relational calculus in terms of R, R , and (x; y) when R is a directed graph that is not necessarily acyclic. We also consider the problem of maintaining transitive closure in a context where some auxiliary relations are available. Dong and Su [7] also obtained results that are similar to ours. However, the proof techniques involved are very di erent. Most importantly, their proof technique is only applicable to the particular case of maintaining transitive closure in relational calculus. Ours is much simpler and can be generalized to more expressive languages and other recursive queries. In particular, instead of transitive closure, any query complete for DLOGSPACE can be used. In Section 3 we show that our technique extends naturally to prove that transitive closure cannot be decrementally maintained using query languages having the power of SQL. That is, we show that the availability of arithmetic operations and GROUP-BY does not help at all. We also extend this result in the presence of simple auxiliary relations. In addition, we exhibit a query that illustrates the additional power of using an SQL-like language incrementally. This query, which is inexpressible in SQL, is expressible incrementally in SQL with certain auxiliary relations but is not expressible incrementally in rst-order logic with the same auxiliary relations. In Section 4, we look at the complexity of maintaining transitive closure against the complexity of maintaining other queries. We prove that it is strictly more di cult to maintain the \\\\same generation\\\" query than to maintain transitive closure. We are also able to generalize this result and show that maintaining context-free chain queries (in a certain sense to be de ned) is at least as hard as maintaining transitive closure. In Section 5 we extend our basic technique to show that the same-generation query cannot be maintained (incrementally or decrementally) in SQL-like languages. 2 Recomputation of Recursive Queries in Relational Calculus The purpose of this section is to show that the transitive closure of a relation cannot be decrementally maintained in relational calculus or rst-order logic. That is, Theorem 2.1 There is no relational calculus expression that de nes the transitive closure R (x;y) of R f(x; y)g in terms of a binary relation R, its transitive closure R, and an edge (x; y). We introduce a new proof technique that is di erent from [7]. In particular, our technique does not rely on games and can be readily extended to other queries and languages. For example, we will show that the analog of Theorem 2.1 holds for a language having the expressive power of SQL.\",\"PeriodicalId\":211031,\"journal\":{\"name\":\"International Workshop/Symposium on Database Programming Languages\",\"volume\":\"18 1\",\"pages\":\"0\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"1995-09-06\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"26\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"International Workshop/Symposium on Database Programming Languages\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.14236/EWIC/DBPL1995.10\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"International Workshop/Symposium on Database Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.14236/EWIC/DBPL1995.10","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 26

摘要

我们研究了在没有递归机制的传统关系语言中维护递归设计视图(如关系的传递闭包)的问题。特别地,我们证明了在删除边的关系演算中传递闭包不能维持。我们使用新的证明技术来证明这个结果。这些证明技术可以推广到其他语言,例如,用于嵌套关系的语言也包含许多聚合函数。本文将这种语言视为SQL的理论重构。我们的证明技术也推广到其他递归查询。因此,我们展示了许多递归查询不能在类似sql的语言中维护。我们证明,在存在某些辅助关系时,这仍然是正确的。我们还将更新传递闭包的复杂性与更新同代查询的复杂性联系起来,并表明后者严格地比前者更难。然后我们将这个结果扩展到基于上下文无关集更新查询的结果。众所周知,关系演算(相当于一阶逻辑)不能表达递归查询,如传递闭包[1]。然而,在真实的数据库系统中,同时存储关系及其传递闭包是合理的,并且在向前者添加边或从后者删除边时更新后者是合理的。这样做被称为视图维护。在本文中,我们考虑的问题是,上述维护传递闭包和其他递归查询的更新问题是否可以使用关系演算或使用其实际的类似sql的扩展来完成。我们还比较了维护传递闭包的复杂性与维护“同一代”和上下文无关的链查询的复杂性。在本文中,我们用字母R表示二元关系,用R表示它的传递闭包。可以证明[6,2],给定R, R和一条新边(x;R的传递闭包R +(x;y) [f(x;Y)g可以用一阶逻辑表示,因此可以用关系演算表示。特别地,对于所有u和v, R +(x;y) (u;v) i R(u;v)或R(u);x)和y = v,或者u = x和R(y;v)或R(u);x)和R(y;因此,可以在关系数据库中增量地维护传递闭包。在移除一条边后更新传递闭包的问题更为复杂。到目前为止,最好的正解是董和苏b[5]。他们证明了如果R是无环的,那么R的传递闭包R (x;y)边为(x;y)可以用R, R和(x)在一阶逻辑中定义;因此,在关系数据库中,如果所涉及的关系是无循环的,则可以递减地维护传递闭包。但这并不令人满意,因为在关系微积分中不能检验非环性。数据库程序设计语言,1995 1论关系微积分和SQL中递归查询的递减重计算的不可能性另一个解决方案是Immerman和Patnaik bbb。他们证明了无向图的传递闭包总是可以保持的,只要使用一些辅助的三元关系。Dong和Su[7]进一步证明了无向图的传递闭包可以只用辅助二元关系来维持。他们还表明,不能只用辅助一元关系来完成。在第2节中,我们证明了传递闭包通常不能在关系数据库中进行递减维护。也就是说,R (x;y)在关系演算中不能用R、R和(x)来表示;y)当R是一个不一定是无环的有向图时。我们还考虑在一些辅助关系可用的上下文中维护传递闭包的问题。Dong和Su[7]也得到了与我们相似的结果。然而,所涉及的证明技术非常不同。最重要的是,他们的证明技术只适用于关系演算中维持传递闭包的特殊情况。我们的查询要简单得多,并且可以推广到更具表现力的语言和其他递归查询。特别是,可以使用DLOGSPACE完成的任何查询,而不是传递闭包。在第3节中,我们展示了我们的技术自然扩展,以证明不能使用具有SQL功能的查询语言以递减方式维护传递闭包。也就是说,我们证明了算术运算和GROUP-BY的可用性根本没有帮助。在存在简单辅助关系的情况下,我们也扩展了这个结果。此外,我们还展示了一个查询,该查询说明了增量使用类sql语言的额外功能。 这个查询在SQL中是不可表达的,但在SQL中可以用一定的辅助关系增量表示,而在具有相同辅助关系的一阶逻辑中不能增量表示。在第4节中,我们将比较维护传递闭包和维护其他查询的复杂性。我们证明了维护“同代”查询比维护传递闭包更严格。我们还能够推广这一结果,并表明维护上下文无关的链查询(在某种意义上有待设计)至少与维护传递闭包一样困难。在第5节中,我们扩展了基本技术,以说明不能在类sql语言中(增量或递减)维护同代查询。2关系演算中递归查询的重计算本节的目的是说明在关系演算或一阶逻辑中,关系的传递闭包不能递减地保持。没有关系演算表达式定义R f(x;)的传递闭包R (x;y)g表示一个二元关系R,它的传递闭包R,和一条边(x;y).我们引入了一种不同于[7]的新的证明技术。特别是,我们的技术不依赖于游戏,可以很容易地扩展到其他查询和语言。例如,我们将展示定理2.1的类比适用于具有SQL表达能力的语言。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
On Impossibility of Decremental Recomputation of Recursive Queries in Relational Calculus and SQL
We study the problem of maintaining recursively-de ned views, such as the transitive closure of a relation, in traditional relational languages that do not have recursion mechanisms. In particular, we show that the transitive closure cannot be maintained in relational calculus under deletion of edges. We use new proof techniques to show this result. These proof techniques generalize to other languages, for example, to the language for nested relations that also contains a number of aggregate functions. Such a language is considered in this paper as a theoretical reconstruction of SQL. Our proof techniques also generalize to other recursive queries. Consequently, we show that a number of recursive queries cannot be maintained in an SQL-like language. We show that this continues to be true in the presence of certain auxiliary relations. We also relate the complexity of updating transitive closure to that of updating the samegeneration query and show that the latter is strictly harder than the former. Then we extend this result to that of updating queries based on context-free sets. 1 Problem Statement and Summary It is well known that relational calculus (equivalently, rst-order logic) cannot express recursive queries such as transitive closure [1]. However, in a real database system, it is reasonable to store both the relation and its transitive closure and update the latter whenever edges are added to or removed from the former. Doing this is known under the name of view maintenance. In this paper we consider the problem of whether the above update problem for maintaining transitive closure and other recursive queries can be accomplished using relational calculus or using its practical SQL-like extensions. We also compare the complexity of maintaining transitive closure against the complexity of maintaining \same generation" and context-free chain queries. In this paper, we use the letter R to denote a binary relation, and R to denote its transitive closure. It can be proved [6, 2] that given R, R, and a new edge (x; y) to be added to R, the transitive closure R +(x;y) of R [ f(x; y)g can be expressed in rst-order logic and thus in relational calculus. In particular, for all u and v, R +(x;y) (u; v) i R(u; v), or R(u; x) and y = v, or u = x and R(y; v), or R(u; x) and R(y; v). Thus transitive closure can be incrementally maintained in a relational database. The problem of updating the transitive closure after an edge has been removed is more di cult. The best positive solution so far is that of Dong and Su [5]. They proved that if R is acyclic, then the transitive closure R (x;y) of R with the edge (x; y) removed can be de ned in rst-order logic in terms of R, R , and (x; y). Thus transitive closure can be decrementally maintained in a relational database provided the relation involved is acyclic. But this is not satisfactory because acyclicity cannot be tested in relational calculus [10]. Database Programming Languages, 1995 1 On Impossibility of Decremental Recomputation of Recursive Queries in Relational Calculus and SQL Another solution is that of Immerman and Patnaik [14]. They proved that transitive closure of undirected graphs can always be maintained, provided some auxiliary ternary relations can be used. Dong and Su [7] strengthened this result further by showing that transitive closure of undirected graphs can be maintained using only auxiliary binary relations. They also showed that it cannot be done using only auxiliary unary relations. In Section 2, we prove that transitive closure cannot be decrementally maintained in a relational database in general. That is, R (x;y) cannot be expressed in relational calculus in terms of R, R , and (x; y) when R is a directed graph that is not necessarily acyclic. We also consider the problem of maintaining transitive closure in a context where some auxiliary relations are available. Dong and Su [7] also obtained results that are similar to ours. However, the proof techniques involved are very di erent. Most importantly, their proof technique is only applicable to the particular case of maintaining transitive closure in relational calculus. Ours is much simpler and can be generalized to more expressive languages and other recursive queries. In particular, instead of transitive closure, any query complete for DLOGSPACE can be used. In Section 3 we show that our technique extends naturally to prove that transitive closure cannot be decrementally maintained using query languages having the power of SQL. That is, we show that the availability of arithmetic operations and GROUP-BY does not help at all. We also extend this result in the presence of simple auxiliary relations. In addition, we exhibit a query that illustrates the additional power of using an SQL-like language incrementally. This query, which is inexpressible in SQL, is expressible incrementally in SQL with certain auxiliary relations but is not expressible incrementally in rst-order logic with the same auxiliary relations. In Section 4, we look at the complexity of maintaining transitive closure against the complexity of maintaining other queries. We prove that it is strictly more di cult to maintain the \same generation" query than to maintain transitive closure. We are also able to generalize this result and show that maintaining context-free chain queries (in a certain sense to be de ned) is at least as hard as maintaining transitive closure. In Section 5 we extend our basic technique to show that the same-generation query cannot be maintained (incrementally or decrementally) in SQL-like languages. 2 Recomputation of Recursive Queries in Relational Calculus The purpose of this section is to show that the transitive closure of a relation cannot be decrementally maintained in relational calculus or rst-order logic. That is, Theorem 2.1 There is no relational calculus expression that de nes the transitive closure R (x;y) of R f(x; y)g in terms of a binary relation R, its transitive closure R, and an edge (x; y). We introduce a new proof technique that is di erent from [7]. In particular, our technique does not rely on games and can be readily extended to other queries and languages. For example, we will show that the analog of Theorem 2.1 holds for a language having the expressive power of SQL.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术官方微信