📜  门| GATE-CS-2004 |第 51 题

📅  最后修改于: 2021-09-26 03:24:39             🧑  作者: Mango

考虑学生关系(姓名、性别、标记),其中主键用下划线显示,与至少有一个男孩和一个女孩的班级中的学生有关。以下关系代数表达式产生什么? (注意:r 是重命名运算符)。
GATECS2004Q51

join中的条件是“(sex =女性^ x =男性^标记≤ m)”
(一)分数最高的女学生名字
(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 提供的。这个问题的测验