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

Database Assignment for CS486 Course

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)
10 views2 pages

Database Assignment for CS486 Course

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

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.

Common questions

Powered by AI

Such analysis can identify gaps in teaching effectiveness or curriculum demand, highlight exceptional students for mentorship, and guide resource allocation more effectively. Understanding relative performance helps tailor interventions to improve student outcomes and adapt curriculum design to meet students' needs better, fostering an environment for excellence .

An SQL query using subqueries and aggregation functions (like AVG) can be designed. It involves calculating the average for each student and comparing it to the departmental average. This query reveals students excelling beyond the average in their department, providing insights into student performance distribution and potentially identifying top performers for scholarships or other recognitions .

Maintaining a log of passing students allows for tracking individual and collective academic progress. This data can be analyzed to assess curriculum effectiveness, identify trends, and inform teaching strategies. It provides actionable insights into which courses might be barriers to student graduation and highlights students or groups excelling or struggling, enabling timely interventions .

Updating the StudentStatistics table for changes in course enrollment is crucial for ensuring accurate academic records, reflecting the true number of credits attained by students each semester. It prevents discrepancies that could affect graduation requirements and performance evaluations. Such updates maintain the reliability and accuracy of academic data used for decision-making and reporting .

Challenges include handling semester overlaps, accurate timestamping, and data normalization issues that could complicate the retrieval. Addressing these requires precise SQL queries utilizing date functions, ensuring consistent data formats, and deploying indexing for efficient query execution. Proper schema design with clear semester definitions can mitigate ambiguity .

The TeachingCapacity table requires defining the instructor_id and course_id as non-nullable and primary keys, with foreign keys referencing the Instructor and Course tables, respectively. The nb_year field should be constrained to hold positive integers only. These constraints ensure data integrity by maintaining the uniqueness of records and enforcing referential integrity between the related tables, which helps in managing relationships and dependencies efficiently .

The StudentStatistics table demonstrates the use of primary keys for uniquely identifying each record and foreign keys for linking data from related tables. This setup ensures each student's statistical record is distinct while also maintaining connections to other pertinent data, like courses and semesters, thereby upholding data integrity by preventing orphan records and unauthorized deletions .

Updating the grade_ABC column based on grade_100 ensures consistency and meaningful grade representation. If implemented incorrectly, it could result in mismatched or incoherent grade reports, leading to integrity issues and potentially impacting academic records. Correct categorization using conditionals ensures accurate grading according to predefined thresholds, which is crucial for maintaining standards and reliability of reported data .

An incorrect foreign key could link students to non-existing or wrong courses, causing misrepresentation of their academic records and leading to faulty reporting or credentialing issues. Ensuring referential integrity through database management best practices—using cascade updates, enforcing foreign key constraints, and implementing integrity checks within the database management system—helps prevent such situations .

Constraints on value domains, such as ensuring nb_year is a positive integer in TeachingCapacity, prevent the entry of erroneous or invalid data, thus maintaining consistency and integrity across the database. They are vital for enforcing business rules, preventing data anomalies, and ensuring reliable query results and decision-making processes .

You might also like