students (sid, sname)
courses (cid, cname, dept)
take (sid, cid, grade)
We want to find student numbers of students who take all courses in department 'CS'.
Why is line 4 the answer?
How does it differ from lines 1 through 3?
I read this in Solved-Ex in DB.
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.