Deferred Constraints

solution 1 using set difference select sid name from

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: course “Operating Systems”. --Solution 1: using set difference select sid, name from student where sid not in (select sid from course_taken ct, course c where ct.course_no = c.course_no and c.name = 'Operating Systems'); --Solution 2: equivalently, you can use the "exists" operator as follows: select s.sid, s.name from student s where not exists (select * from course_taken ct, course c where ct.course_no = c.course_no and c.name = 'Operating Systems' and ct.sid = s.sid); --Solution 3: using outer join select s.sid, s.name from student s left outer join (select sid, course_no from course_taken ct natural join course where name = 'Operating Systems') os_taking on s.sid = os_taking.sid where course_no is null; _____________________________________________ Before we continue, let us update the COURSE_TAKEN table. SQL UPDATE Syntax: UPDATE <table_name> SET column1=value1, column2=value2, … WHERE some_column =some_value; __________________________________________________________________ 5. Find the SID(s) of the student(s) who has(have) the highest GPA. --1: following the intuition: the students that has highest GPA are those whose GPA is greater than or equal to all of the students. The condition "avg(ct2.grade) is not null" is used to avoid the issue with null comparison (any comparison with one operand bei...
View Full Document

Ask a homework question - tutors are online