关系代数中的算术除法

Arithmetic division in relational algebra

我有一个 SQL 请求:

SELECT table1.nr1 / NULLIF(table2.nr2, 0) as percentage

我想用关系代数来写这个。

可以用关系代数表示算术除法吗?

根据this course of the University of Rochester关系代数可以定义为

a formal system for manipulating relations

  • Operands of this algebra are relations.
  • Operations of this algebra include the usual set operations (since relations are sets of tuples), and special operations defined for relations

    • selection

    • projection

    • join

这是一门关于关系的代数,没有数字的表示。如果你想对数字使用算术,你必须使用扩展的形式主义,例如 Safe Database Queries with Arithmetic Relations.