6-5.A less obvious example of a difference query would be to find a difference t
ID: 3604120 • Letter: 6
Question
6-5.A less obvious example of a difference query would be to find a difference that is not based on simple, easy-to-get sets. Suppose that set A is the set of students who have earned A's and B's in computer science (COSC) courses. Suppose further that set B is the set of students who have taken math courses (regardless of what grade they earned) Then, set A minus set B would contain names of students who have earned A's or B's in computer science courses, less those who have taken math courses. Similarly, set B minus set A would be the set of students who took math courses, less those who took COSC courses and earned an A or a B in COSCxxxx Build these queries into set difference queries as views based on student numbers and execute them. First, run a query that gives the student number, name, course, and grade for each set. Save each query as Q65a and Q65b. After saving each query, reconstruct it into a view of just student numbers, verify that it works, and then use create view to create set A and set B. Verify that you have the same number of tuples in set A as you have in Q65a and in set B as in Q65b. a. b. c. Then, display the student numbers of students in each set difference-show (set A minus set B) and (set B minus set A). Look at the original queries, Q65a and Q65b, to verify your result.Explanation / Answer
Step 1 : Create one table with tblStudent with following field.
Number
Name
Course
Grade
Couese Is 'COSC' For Computer Science And 'MATH' For math
dummy record used
Answer Is as follow
Answer (A) :
Query for selecting SET A
Query for selecting SET B
Answer (B) :
Create View for SET A
Create View vwCOSC as
Select Number, Name from tblStudent Where Course Like 'COSC' And (grade Like 'A' Or grade Like 'B')
Create View for SET B
Create View vwMATH as
Select Number, Name from tblStudent Where Course Like 'MATH'
Answer (C) :
Query for Set Difference Of SET A - SET B
Select vwCOSC.Number from vwCOSC
Where vwCOSC.Number not in ( select vwMATH.Number from vwMATH )
Query for Set Difference Of SET B - SET A
Select vwMATH.Number from vwMATH
Where vwMATH.Number not in ( select vwCOSC.Number from vwCOSC )
number name Course grade 1 A COSC C 2 B COSC A 3 C COSC B 4 D COSC A 5 E COSC B 6 F COSC B 7 G COSC A 8 H COSC A 9 I COSC B 10 J COSC A 1 A MATH 2 B MATH 3 C MATH 4 D MATH 11 K MATH 12 L MATHRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.