Lab#4 233070 DBMS
Lab#4 233070 DBMS
ROLL NO : 233070
DEPARTMENT : BSCGD 2A
LAB TASK : DBMS
Lab Task
Given the following database schema:
Student (snum: integer, sname: char(30), major: char(25), level: char(2))
Faculty (fid: integer, fname: char(30), deptid: integer)
Class (cname: char(40), meets_at: char(20), room: char(10), fid: integer |
fid REFS Faculty.fid)
Enrolled (snum: integer, cname: char(40) | snum REFS student.snum,
cname REFS class.name)
Write SQL expressions for each of the following queries and execute them:
Task 1:
Find the names of all juniors (Level = JR) who are enrolled in a class taught by ‘Ivana Teach’.
Task 2:
Find the names of faculty members that has taught classes only in room R128.
Task 3:
Find the names of classes taught by ‘Richard Jackson’ and their times when a class meet there.
Task 4:
Find the names of students majoring in ‘Computer Science’.
Task 5:
Find the names of classes taught by ‘John Williams’ in dept # 68.
Task 6:
For each class taught by ‘John Williams’, retrieve the name and age for students.
Task 7:
Find the names of students in ‘Computer Science’ major in descending age-wise.
Task 8:
Task 9:
Task 10:
Retrieve the snum and sname of students who have taken classes from both ‘Ivana Teach’ and ‘Linda
Davis’. (Both with simple and nested queries)
Task 11:
Task 12:
Find the average age of student in course: ‘Organic Chemistry’.
Task 13:
Task 14:
Find youngest student in ‘Electrical Engineering’ major.
Task 15:
Task 16:
Task 17:
Find the number of distinct class rooms
Task 18:
Find the strength of students in each major.
Task 19:
Find strength of students in course: ‘Urban Economics’
Task 20: