R÷S应该如何理解和计算?
学习数据库系统的时候,对习题中的除关系代数操作不是很理解,经课下学习其他博客总结如下,写在复习时留用。
相关定义
NOTATION: r÷s
-
Suited to queries that include the phrase “for all”.
——适用于检索语句中含有“所有的”的情况 -
Let r and s be relations on schemas R and S respectively where
R = (A1, …, Am , B1, …, Bn )
S = (B1, …, Bn)
3.The result of r ÷s is a relation on schema
R - S = (A1, …, Am)
——即找到R中所有不在S中的属性
4.Where tu means the concatenation of tuples t and u to produce a single tuple (each t concatenation all u)
参照例题理解
例题1.
理解&计算
R÷S?
1.R-S=(A)
——在R中不在S中的属性只有A
2.计算A属性的域
3.B属性的取值有1和2两种;
那么,在R关系中,对于A属性的5种取值,哪些取值对应行的B属性取值覆盖了1和2两种。
R关系中AB属性的值:
符合上述要求的在下图圈出来,比如α对应的B属性可以取1和2,所以α符合题意。而γ只能取到1,不能取2,故γ不符合题意。
4.R÷S=
练习题附答案
R÷S=?
答案:
R÷S=