Anorther comment regarding student database 2.
In the last excercise, we are asked to:
List of courses, in alphabetical order, with only one student enrolled:
The correct answer given in hints is the following:
SELECT course FROM students RIGHT JOIN majors USING(major_id) INNER JOIN majors_courses USING(major_id) INNER JOIN courses USING(course_id) GROUP BY course HAVING COUNT(course) = 1 ORDER BY course;
Which gives the following result:
However, I don’t believe this is correct. Server Administration and UNIX are correct, but Network Security is not. Network Security is only in one major, Network Engineering, and no students are taking this major.
In addition to this, Computer Systems and Computer Network courses are both in 3 majors: Computer Programming, Network Engineering and System Administration. Computer Programming and Network Engineering have no students, and System Administration has 1 student. Therefore, there should be part of the correct answer.
My proposed correct answer is:
To obtain this answer, my proposed solution is:
SELECT course FROM students INNER JOIN majors_courses USING(major_id) INNER JOIN courses USING(course_id) GROUP BY course HAVING COUNT(student_id) = 1 ORDER BY course;