Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views2 pages

(IC) Topic04 ComplexSQLQueriesReview

The document outlines an in-class assignment for CS486 – Introduction to Databases, led by Lê Thị Nhàn, PhD. It includes tasks such as creating tables with constraints, inserting sample data, updating grade columns, and retrieving student statistics using SQL queries. The assignment emphasizes database management and data manipulation skills using SQL Management Studio or Azure Data Studio.
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)
11 views2 pages

(IC) Topic04 ComplexSQLQueriesReview

The document outlines an in-class assignment for CS486 – Introduction to Databases, led by Lê Thị Nhàn, PhD. It includes tasks such as creating tables with constraints, inserting sample data, updating grade columns, and retrieving student statistics using SQL queries. The assignment emphasizes database management and data manipulation skills using SQL Management Studio or Azure Data Studio.
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/ 2

CS486 – Introduction to Databases

​ Lecturer: ​ Lê Thị Nhàn, PhD.


​ TA: ​ Phan Thị Phương Uyên, MSc.
​ Lab instructor:​ Nguyễn Ngọc Toàn, MSc.
​ ​ Nguyễn Ngọc Minh Châu, MSc.
​ ​
In-class assignment
Task 1: Use University database (run UniversityDB_script file on moodle to create the database).
Utilize the SQL editor of SQL Management Studio or Azure Data Studio to write the following
queries:
1.​ Create the following tables with necessary constraints (PK, FK, the constraints on value
domain):
○​ TeachingCapacity
■​ instructor_id: varchar(9) not null primary key, reference to the Instructor table.
■​ o course_id: varchar(9) not null primary key, reference to the Course table.
■​ o nb_year: int (>0).
2.​ Insert the sample data in the tables above.
3.​ Update the grade_ABC column of the GradeReport table based on the values in the
grade_100 column:
○​ 90-100: A,
○​ 80-89: B,
○​ 70-79: C,
○​ 65-69: D.
○​ 50-65: E,
○​ <50: F
4.​ Find the ID and name of each student, along with the average grade (grade_100) of the
courses they have passed, where a passed course is defined as having a grade_100 of 50
or higher.
5.​ Retrieve the code and name of ALL students, along with the count of courses they have
passed,where a passed course is defined as having a grade_100 of 50 or higher.
6.​ Retrieve the count of courses taught in each semester of every year. Return the year,
semester, and the count of courses.
7.​ For each department, find the student(s) with the highest average grade across all enrolled
sections. Return the department_id, department name, student_id, student name and
average grade.
8.​ List students whose average grade is higher than the average of all students in their
department.
9.​ Create the StudentStatistics table with the primary key and all necessary foreign keys to
summarize student information. The table should include the following columns: student_id,
student_name, school_year, semester, and nb_credits (representing the total number of
credits for the courses enrolled in each semester of each school year). After creating the
table, populate it using data extracted from the existing database.
10.​Suppose that students may have made changes to their course enrollment, update the
StudentStatistics table to ensure that the nb_credits remains consistent.

You might also like