0% found this document useful (0 votes)
40 views

CSE302 5 Labwork4

The document describes the schema of a university database including tables for classrooms, departments, courses, instructors, sections, student enrollment, prerequisites, and others. It also provides foreign key relationships and lists multi-part queries to retrieve information from the database.

Uploaded by

Md. Yeasin
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)
40 views

CSE302 5 Labwork4

The document describes the schema of a university database including tables for classrooms, departments, courses, instructors, sections, student enrollment, prerequisites, and others. It also provides foreign key relationships and lists multi-part queries to retrieve information from the database.

Uploaded by

Md. Yeasin
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/ 3

EAST WEST UNIVERSITY

Department of Computer Science & Engineering


B.Sc. in Computer Science and Engineering Program
Lab 4, Fall 2023 Semester

Course: CSE302 Database Systems, Section-5


Instructor: Md. Mohsin Uddin, Senior Lecturer, Department of CSE

Consider the following schema diagram of a university database.

Page 1 of 3
The underlined attributes in the database tables are considered as primary key.

• classroom(building, room number,capacity);

• department(dept name, building, budget);

• course(course id, title, dept name, credits);

• instructor(ID, name, dept name, salary);

• section(course id, sec id, semester, year, building, room number, time slot id);

• teaches(ID, course id, sec id, semester, year);

• student(ID, name, dept name, tot cred);

• takes(ID, course id, sec id, semester, year, grade);

• advisor(s ID, i ID);

• time slot(time slot id, day, start hr, start min, end hr, end min);

• prereq(course id, prereq id);

The foreign key relations are mentioned below:

• dept name in course is a foreign key referencing department.

• dept name in instructor is a foreign key referencing department.

• course id in section is a foreign key referencing course.

• (building, room number) in section is a foreign key referencing classroom.

• (course id,sec id, semester, year) in teaches is a foreign key referencing section.

• ID in teaches is a foreign key referencing instructor.

• dept name in student is a foreign key referencing department.

• (course id,sec id, semester, year) in takes is a foreign key referencing section.

• ID in takes is a foreign key referencing student.

• i ID in advisor is a foreign key referencing instructor (ID).

• s ID in advisor is a foreign key referencing student (ID).

• course id in prereq is a foreign key referencing course.

• prereq id in prereq is a foreign key referencing course.

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.

g. Give a 5% salary raise to instructors whose salary is less than average.

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.

k. Find the ID and the grade-point average of every 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

You might also like