CSE302 5 Labwork4
CSE302 5 Labwork4
Page 1 of 3
The underlined attributes in the database tables are considered as primary key.
• section(course id, sec id, semester, year, building, room number, time slot id);
• time slot(time slot id, day, start hr, start min, end hr, end min);
• (course id,sec id, semester, year) in teaches is a foreign key referencing section.
• (course id,sec id, semester, year) in takes is a foreign key referencing section.
Page 2 of 3
Considering the above database relations, Write Structured Query Language (SQL) com-
mand/statement for each of the following queries:
a. Find the names of all instructors who have taught some courses and the course id
b. Find the names of all instructors who have a higher salary than some instructor in ‘Comp.
Sci’.
c. Find all the courses taught in the Fall 2009 semester but not in the Spring 2010 semester.
d. Find the total number of (distinct) students who have taken course sections taught by the
instructor with ID 110011.
e. Delete all tuples in the instructor relation pertaining to instructors in the Finance depart-
ment.
f. Delete all tuples in the instructor relation for those instructors associated with a department
located in the Watson building.
h. All instructors with salary over $100,000 receive a 3% raise, whereas all others receive a 5%
raise.
i. Find the IDs of all students who were taught by an instructor named Einstein; make sure
there are no duplicates in the result.
j. Find the total grade-points earned by the student with ID 12345, across all courses taken
by the student.
l. Find the names of all students who have taken at least one Comp. Sci. course; make sure
there are no duplicate names in the result.
m. Find the IDs and names of all students who have not taken any course offering before Spring
2009.
n. For each department, find the maximum salary of instructors in that department. You may
assume that every department has at least one instructor.
o. Find the lowest, across all departments, of the per-department maximum salary computed
by the preceding query.
Page 3 of 3