Lab Assignment: Database Systems
Given the following relational database schema:
Student = (SSN, Name, Major)
Course = ( CourseNumber, PrerequisiteCourseNumber, Course Title, NumberUnits)
Section = ( CourseNumber, Quarter, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00PM.
Enrollment = (SSN,CourseNumber, Quarter, Grade)// Grade is either Null or a letter grade.
Express the following queries using appropriate SQL statements with a minimum number of operations:
A. List the name, SSN and the number of courses the student has taken (courses with the same CourseNumber taken in different quarters are counted as different courses).
B. Answer #A assuming courses with the same CourseNumber taken in different quarters are considered as one course.
C. List the name, SSN and number of courses the student has taken and completed, i.e. received a letter grade (courses with the same CourseNumber taken in different quarters are counted as different courses).
D. List the name, SSN and number of courses the student has taken and completed with a letter grade C or better (courses with the same CourseNumber taken in different quarters are counted as different courses).
E. List the Course Title and CourseNumber which does not have any prerequisite.
F. List the name of every student and SSN who earned an A in all courses he or she has completed, i.e. every grade is either Null or an A).
G. List the name of every student, SSN and the CourseNumber who has taken the course at least three times.
H. List the name of every student, SSN, every quarter, and the number of courses he or she has taken in the listed quarter.
I. List the name of every student and SSN who has not taken any course more than once.
J. List the name, SSN , the number of courses the student has taken, and the number of courses completed(courses with the same CourseNumber taken in different quarters are counted as different courses).
K. List every two CourseNumber and their titles which have the same prerequisites.
L. List the name of every student and SSN who has completed all the courses he/she has taken and earned an A in each course, i.e. every grade is an A and no NULL value
M. List the name of every student and SSN who earned no A in any course.
N. List the name and major of every student who has only taken courses that meet MW afternoon (12 or after).
O. List the name and major of every student who has taken all the courses that meet MW afternoon.
P. List the name and major of every student who has not taken any course that meets MW afternoon.
Q. List every CoursaeNumber and Quarter which has the highest enrollment.
R. List every CourseNumber and CourseTitle which has the highest enrollment based on all quarters.
S. List the name and major of every student who has completed the highest number of units.
T. List every Course tile which is a prerequisite for the largest number of courses.