hw3 spr23
hw3 spr23
Homework 3
Due: March 21, Tuesday till midnight
You will use the Moodle course page for submission of this assignment
Q.1 [20 pts, 5 pts each] Consider the following relational schema:
student (s-id, s-name, department, cgpa)
club (c-id, c-name)
membership (s-id, c-id, since)
s-id is a foreign key to student, c-id is a foreign key to club
(c) ∏c-id, c-name, cnt (σcnt > 100 (c-id, c-name count(*) as cnt (club membership) ) )
Q.2 [80 pts, 8 pts each] Given the following relational schema for a course grading system:
Students(TCK, sname, sdept, cgpa)
Courses(cid, cname, cdept, credit)
Grades(TCK, cid, grade) TCK is a foreign key to Students,
cid is a foreign key to Courses
(a) Find the students (TCK, sname) who have taken a grade higher than 90 in a 4 credit
course from the CS department.
(b) Find the CS students (TCK, sname) whose cgpa is higher than 3.50, but have not taken
any course from the EE department.
(c) Find the CS student(s) (TCK, sname) with the highest cgpa.
(d) Find the CS courses (cid, cname) which have been taken by the students of at least 5
different departments.
(e) Find the students (TCK, sname) who have received a grade of 100 in at least 5 courses.
(f) For each course of each department, find the average of student grades. Give the resulting
list in increasing alphabetical order of department names.
(g) For each department, find the course(s) (cid) which has the highest of average of student
grades. Give the resulting list in increasing alphabetical order of department names.
(h) Find the student(s) (TCK, sname) whose cgpa is higher than the average cgpa of his/her
department.
(i) For each department, find the student(s) (TCK, sname) with the highest cgpa. Give the
resulting list in increasing alphabetical order of department names.
(j) Find pairs of students (TCK) who are from different departments and have taken at least
10 common courses. Each pair should be listed only once.