一句话:用伴随与分级 monad 为关系代数的连接、分组等操作提供范畴论基础,并导向高效实现。
集合、包和列表等 bulk types 是 monad,因而可用基于 comprehension 的记法表达数据库查询;monad 结构能自然解释选择与投影,却无法直接解释关系连接与分组,最多只能表示为笛卡尔积后接选择。论文转向范畴论中的伴随:bulk types 本身也由特定伴随产生,通过关注其他重要伴随,可为标准关系代数的其余操作提供优雅基础。特别地,graded monad 为索引与分组提供数学基础,并直接导向高效实现,甚至可用于连接。该工作以理论构造与示例分析为主,未报告实证评估。
Bulk types such as sets, bags, and lists are monads, and therefore support a notation for database queries based on comprehensions. This fact is the basis of much work on database query languages. The monadic structure easily explains most of standard relational algebra---specifically, selections and projections---allowing for an elegant mathematical foundation for those aspects of database query language design. Most, but not all: monads do not immediately offer an explanation of relational join or grouping, and hence important foundations for those crucial aspects of relational algebra are missing. The best they can offer is cartesian product followed by selection. Adjunctions come to the rescue: like any monad, bulk types also arise from certain adjunctions; we show that by paying due attention to other important adjunctions, we can elegantly explain the rest of standard relational algebra. In particular, graded monads provide a mathematical foundation for indexing and grouping, which leads directly to an efficient implementation, even of joins.
@article{paperbot283,
title = {Relational algebra by way of adjunctions},
author = {Jeremy Gibbons and Fritz Henglein and Ralf Hinze and Nicolas Wu},
journal = {Proceedings of the ACM on Programming Languages},
volume = {2},
number = {ICFP},
year = {2018},
doi = {10.1145/3236781}
}