0% found this document useful (0 votes)
4 views1 page

Lab 03

This document outlines the instructions for Lab Assignment 3 for CS621, which involves SQL queries based on a student database created in a previous lab. The assignment includes ten specific queries related to student and faculty data, each worth one mark, with an emphasis on avoiding duplicates in the results. Additionally, 50% of the total marks are allocated for a viva component.

Uploaded by

kapishagl28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Lab 03

This document outlines the instructions for Lab Assignment 3 for CS621, which involves SQL queries based on a student database created in a previous lab. The assignment includes ten specific queries related to student and faculty data, each worth one mark, with an emphasis on avoiding duplicates in the results. Additionally, 50% of the total marks are allocated for a viva component.

Uploaded by

kapishagl28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS621 : Lab Assignment 3

1 INSTRUCTIONS
(1) This lab is graded.
(2) Use the student database that was created in Lab2.
(3) Each question carries 1 mark. 50% of the total marks are for the viva.

2 QUESTION 1
Consider the following relations:
Student(snum: integer, sname: string, major: string, level: string, age: integer)
Class(name: string, meets_at: time, room: string, fid: integer)
Enrolled(snum: integer, cname: string)
Faculty (fid: integer, fname: string, deptid: integer)
The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such
that the student is enrolled in the class.
Write the following queries in SQL. No duplicates should be printed in any of the answers.
(1) For each level, print the level and the average age of students for that level.
(2) For all levels except FR, print the level and the average age of students for that level.
(3) For each faculty member that has taught classes, print the faculty member’s name and the total number of classes
she or he has taught.
(4) Find the name and number of students who have enrolled in Operating System Design but not in Database
Systems.
(5) Find the average age of all students taking a course, if that course has at least 2 students.
(6) Find the ids of faculty members who are teaching more than one course.
(7) Find the classes for which no student has enrolled.
(8) List students (their ids, names, majors , level and age) in descending order of age.
(9) Find the names and ids of all students whose major is not some branch of Engineering (Electrical Engineering,
Mechanical Engineering, Computer Engineering, Civil Engineering).
(10) Count the number of students in each branch of Engineering.

.
1

You might also like