Category theory offers a mathematical foundation for knowledge representation and database systems. Popular existing approaches model a database instance as a functor into the category of sets and functions, or as a 2-functor into the 2-category of sets, relations, and implications. The functional and relational models are unified by double functors into the double category of sets, functions, relations, and implications. In an accessible, example-driven style, we show that the abstract structure of a 'double category of relations' is a flexible and expressive language in which to represent knowledge, and we show how queries on data in the spirit of Codd's relational algebra are captured by double-functorial semantics.
翻译:范畴论为知识表示与数据库系统提供了数学基础。现有主流方法将数据库实例建模为进入集合与函数范畴的函子,或建模为进入集合、关系及蕴含关系的2-范畴的2-函子。通过引入进入集合、函数、关系及蕴含关系的双范畴的双函子,函数模型与关系模型得以统一。本文以通俗易懂的示例驱动方式,论证了"关系双范畴"的抽象结构是一种灵活且富有表现力的知识表示语言,并阐明了如何通过双函子语义来捕捉柯德关系代数思想下的数据查询操作。