Example 1: Display a list of all students, their ID, name and dept_name and tot_cred along with the courses they have taken
The query does NOT work. Since natural join drops any tuple that does not match with the second relation’s tuple. The students with no courses will not get matched, therefore would not appear in the result.
Example 2: Find all students who have not taken a course
There it will output Snow, since he doesn’t take any courses, course id is null since all attributes of tuple are filled with null values.
Example 3: right outer join
of takes and student relations
- First few attributes come from
takes
then fromstudent
- Since it’s
right outer join
, it preserves tuples from student (which is the right in our case) and pad withnull
all other attributes.
Example 4: full outer join