Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

B) Find courses that ran in Fall 2009 and in Spring 2010 only. Between these que

ID: 3794764 • Letter: B

Question

B) Find courses that ran in Fall 2009 and in Spring 2010 only.

Between these queries (Query 1 - 6), which would produce the same results having these applied on our class running example, the University relational database with the small size tables? Query 1) select distinct course_id from section where semester = 'Fall' and year= 2009 and course_id in (select course_id from section where semester = 'Spring' and year= 2010); Query 2) select course_id from section where semester = 'Fall* and year = 2009 intersect select course_id from section where semester = 'Spring' and year = 2010; Query 3) select course_id from section where semester = "Fall" and year = "2009" and semester = "Spring" and year = "2010"; Query 4) select T.course_id from section as T, section as S where T.semester = "Fall" and T.year = "2009" and S.semester = "Spring" and S.year = "2010" and T.course_id = S.course_id; Query 5) select course_id from section as S where semester = 'Fall' and year = 2009 and exists (select * from section as T where semester = 'Spring' and year= 2010 and S.course_id = T.course_id); Query 6) select course_id from section as T join section as S using (course_id) where T.semester = "Fall" and T.year = "2009" and S.semester = 'Spring" and S.year = "2010";

Explanation / Answer

A)Query 1: this query displays the course ID from section table where semester is fall and year is 2009 and semester is spring and year is 2010.

Query 2) intersect is usually used to merge data from two table here there is a single table so it is not necessary to use the intersect but olit produce the list is output what the query 3 produce.

Query 3) This is simplest way to retrieve our data from the table .

Query 4&6 ) The usuage of join is not necessary in this case since it is derived from single table.

Query 5) we can use exist key word to add subquery hence this is also a method that produce the same output.

B)query 3) select course_id from section where semester=fall and year ='2009' and semester ='spring' and year = '2010'