考虑学生关系(名称,性别,标记),其中主键用下划线显示,该关系与班级中至少有一个男孩和一个女孩的学生有关。以下关系代数表达式产生什么? (注意:r是重命名运算符)。
加入的条件是“(性别=女性^ x =男性^标记≤m)”
(A)分数最高的女学生的名字
(B)比某些男生分数更高的女学生的名字
(C)分数不少于男生的女学生的名字4)
(D)比所有男生都拥有更多分数的女生的名字答案: (D)
解释:
The above relational algebra expression has two sub expressions.
The first one takes as input the Student relation (Student) and filters
out all the tuples where sex=female(r sex=female (Student))
and then projects their names (P name r sex=female (Student)).
So we get a new relation with names of all the female students.
The second one takes as input the Student relation and performs a rename
operation on one with attributes name, sex and marks renamed as n, x, m
respectively (r n, x, m(Student)) and then followed by a self-Cartesian
product on the Student relation. The condition (sex = female ^ m = male ^ marks ≤ m)
filters tuples with all female students from the first relation,
male students from the second relation and performs a Cartesian product where
marks of the female student is either less than or equal to a male student and
then projects their names. So we get a new relation with names of all female
students whose marks are lesser than at least one of the male student.
两个子表达式之间的差异运算符(-)给出所有名称
成绩高于班上所有男生的女学生。
(从所有女学生的名字中,我们删除所有标记在
至少一个男学生)
该解释由Yashika Arora提供。这个问题的测验