理解关系代数中的除法

Understanding Division in Relational Algebra

我无法理解这张关于关系代数除法的幻灯片。我做了一些研究,很多人提到 On Making Relational Algebra Comprehensible by Lester I McCann. 我在理解其中一张幻灯片(幻灯片 13)时遇到了问题。我基本上重新制作了下面的幻灯片。

Query: Find the sno value of the suppliers that supply all parts of weight equal to 17.

Relation P

+-------------------------------+
| pno pname color weight city   |
+-------------------------------+
| P1  Nut   Red   12.0   London |
| . . . . . . . . . . . . . . . |
| P6  Cog   Red   19.0   London |
+-------------------------------+

Relation SPJ

+-------------------------+
| sno pno jno qty         |
+-------------------------+
| S1  P1  J1  200         |
| . . . . . . . . . . . . |
| S5  P6  J4  500         |
+-------------------------+

我知道我需要以下架构。关系 A 投影 sno, pno 的列表。关系 B 告诉您哪个 pno 等于 17 权重。

α (sno, pno)
β (pno) 
α ← π sno,pno (SPJ)
β ← π pno (σ weight=17 (P))

Result:

Relation α

+---------+
| sno pno |
+---------+
| S1 P1   |
| S2 P3   |
| S2 P5   |
| S3 P3   |
| S3 P4   |
| S4 P6   |
| S5 P1   |
| S5 P2   |
| S5 P3   |
| S5 P4   |
| S5 P5   |
| S5 P6   |
+---------+

Relation β:

+-----+
| pno |
+-----+
| p2  |
| p3  |
+-----+

但是幻灯片接着说:

Find the values that do not belong in the answer, and remove them from the list of possible answers.

In our P–SPJ example, the list of possible answers is just the available sno values in α:

+-----+
| sno |
+-----+
| S1  |
| S2  |
| S3  |
| S4  |
| S5  |
+-----+

这就是我卡住的地方。他在示例中说 "P - SPJ" 但如果我这样做,我就不会得到上面的关系。我不认为甚至可以做 P - SPJ?根据数据库系统第一课,当我们对关系应用差异操作时,这两个表需要具有具有相同属性集的模式(P 和 SPJ 没有)?

如果有人能给我指出正确的方向,那将非常感谢!我有本书 数据库系统第一课,第 4 章教授关系代数,但不幸的是没有教授除法(这是我偶然发现并想学习的)。

Find the values that do not belong in the answer, and remove them from the list of possible answers.

当他们说 "Find the values that do not belong in the answer" 时,那是他们后来做的事情。 "values that do not belong" 的关系将是 π sno (δ).

当他们说 "and remove them from the list of possible answers" 时,他们的意思是答案是他们最终在接下来找到的 "list of possible answers" 关系和之后找到的 π sno (δ) 之间的关系差异.

In our P–SPJ example, the list of possible answers is just the available sno values in α:

当他们说 "In our P-SPJ example, ..." 时,他们只是指 "In our example involving relations P & SPJ, ..."。他们正在使用破折号;他们没有对关系差异使用减号。他们接下来计算并显示的是 "list of possible answers" 关系 π sno (α).

(最后他们得到答案,就是π sno (α) - π sno (δ)。)