Databases have been studied category-theoretically for decades. The database schema -- whose purpose is to arrange high-level conceptual entities -- is generally modeled as a category or sketch. The data itself, often called an instance, is generally modeled as a set-valued functor, assigning to each conceptual entity a set of examples. While mathematically elegant, these categorical models have typically struggled with representing concrete data such as integers or strings. In the present work, we propose an extension of the set-valued functor model, making use of multisorted algebraic theories (a.k.a. Lawvere theories) to incorporate concrete data in a principled way. This also allows constraints and queries to make use of operations on data, such as multiplication or comparison of numbers, helping to bridge the gap between traditional databases and programming languages. We also show how all of the components of our model -- including schemas, instances, change-of-schema functors, and queries - fit into a single double categorical structure called a proarrow equipment (a.k.a. framed bicategory).
翻译:数据库的范畴论研究已有数十年历史。数据库模式——其目的在于组织高层次概念实体——通常被建模为范畴或略图。数据本身(常称为实例)通常被建模为集值函子,为每个概念实体分配一组示例。尽管数学上优雅,这些范畴模型在表示具体数据(如整数或字符串)方面通常存在困难。在本研究中,我们提出对集值函子模型的扩展,利用多类代数理论(亦称Lawvere理论)以原则性方式纳入具体数据。这同时允许约束和查询利用数据上的运算(如数字的乘法或比较),有助于弥合传统数据库与编程语言之间的鸿沟。我们还展示了模型的所有组件——包括模式、实例、模式变换函子及查询——如何融入称为箭头装备(亦称框架双范畴)的单一双范畴结构。