用于查找没有匹配项的行的关系代数
Relational algebra to find rows that do not have matches
我有三个关系:
Course(courseNum, units, time, room)
Student(ID, name, degree)
Takes(ID, courseNum)
我需要一个关系代数表达式,它显示没有研究生的课程列表以及相关信息(courseNum、单位、时间、房间)。
如何使用关系代数找到表示“这门课程没有研究生”的关系?
how can I use the relational algebra to find a relation that indicates this course does not have grad students?
R MINUS S
包含 R 中但不在 S 中的行。
因此,如果具有属性 r1 的 R,... 包含从某些 (特征)谓词(句子模板)r 由 r1, ... 和具有属性 r1, ... 的 S 参数化,... 包含从某些谓词 s 就 r1 而言,... 然后 R MINUS S
持有从谓词 r
AND NOT
[=46= 中得出真命题的元组]s
.
同样JOIN
对应AND
,UNION
对应OR
,PROJECT
attributes kept
到EXISTS
attributes dropped
,RESTRICT
condition
到AND
condition
,等等。这就是我们知道如何构建特定查询的方式——我们使用关系运算符 return 我们想要的元组,因为 base/named 关系持有(通过更新)满足其谓词的元组(根据设计)。
(要使用 MINUS
& UNION
我们有时必须重新排列谓词表达式以获得具有相同属性的参数表达式。我们已经得到任何 NOT
出现在AND NOT
。这通常是通过应用德摩根定律和分配定律来完成的。Find the names of students who are not enrolled in any course - Students, Faculty, Courses, Offerings, Enrolled)
Relational algebra for banking scenario
Is there any rule of thumb to construct SQL query from a human-readable description?
我有三个关系:
Course(courseNum, units, time, room)
Student(ID, name, degree)
Takes(ID, courseNum)
我需要一个关系代数表达式,它显示没有研究生的课程列表以及相关信息(courseNum、单位、时间、房间)。
如何使用关系代数找到表示“这门课程没有研究生”的关系?
how can I use the relational algebra to find a relation that indicates this course does not have grad students?
R MINUS S
包含 R 中但不在 S 中的行。
因此,如果具有属性 r1 的 R,... 包含从某些 (特征)谓词(句子模板)r 由 r1, ... 和具有属性 r1, ... 的 S 参数化,... 包含从某些谓词 s 就 r1 而言,... 然后 R MINUS S
持有从谓词 r
AND NOT
[=46= 中得出真命题的元组]s
.
同样JOIN
对应AND
,UNION
对应OR
,PROJECT
attributes kept
到EXISTS
attributes dropped
,RESTRICT
condition
到AND
condition
,等等。这就是我们知道如何构建特定查询的方式——我们使用关系运算符 return 我们想要的元组,因为 base/named 关系持有(通过更新)满足其谓词的元组(根据设计)。
(要使用 MINUS
& UNION
我们有时必须重新排列谓词表达式以获得具有相同属性的参数表达式。我们已经得到任何 NOT
出现在AND NOT
。这通常是通过应用德摩根定律和分配定律来完成的。Find the names of students who are not enrolled in any course - Students, Faculty, Courses, Offerings, Enrolled)
Relational algebra for banking scenario
Is there any rule of thumb to construct SQL query from a human-readable description?