问题
We have 3-Relation:
Students(sid, sname)
Courses(cid, cname, dept)
take(sid, cid, grade)
We want to find student numbers of students whose these students take all courses that present in 'CS' department
.
why (line 4) is the answer of this query ?
anyone could say differ from (line 1) to (line 3). I read this in Solved-Ex in DB.
回答1:
Another way to phrase the fourth line is:
all students
except
(
all combinations of students and CS courses
except
all taken courses
)
The set between brackets contains all student + CS course combinations that were not taken. Subtract this from all students, and you get the students that did take all CS exams.
来源:https://stackoverflow.com/questions/28942035/relational-algebra-and-confusing-one-complex-examples