Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

SQL

Uploaded by

tmibui2000
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SQL

Uploaded by

tmibui2000
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Answer the following SQL questions, the relational schema and data are given below.

These
tables are part of a university database containing data about students, lecturers, courses,
classes, and the grades student get after taking some courses. Grades are given to students by
a lecturer for a class taught in a given semester and year. The adviser of a student is a lecturer.

Course (course_code, course_name)


Lecturer (lecturer_id, lecturer_name, office, position)
Class (class_code, Course.course_code course, semester, year, Lecturer.lecturer_id lecturer)
Student (student_id, student_name, Lecturer.lecturer_id advisor)
Enrol (Student.student_id student, Class.class_code class, grade)

Lecturer
lecturer_id lecturer_name office position
1 Elaine Chen 2.4.27 Lecturer

2 George Michael 2.4.28 Head of School

3 Anthony Kramer 2.4.29 Senior Lecturer

4 Ha Quoc Nguyen 2.4.27 Associate Lecturer

5 Nguyen Ngoc Thanh 2.4.27 Lecturer

Student
sid name adviser
1 Ha 1

2 Phuc 2

3 Tien

4 Khang 1

5 Anh 2

6 Trong

Enrol
student class grade
3 81_2022A 60

2 14_2022A 65

1 39_2021B 70
Enrol
student class grade
2 39_2021B 75

3 39_2021B 55

1 14_2022A 85

2 14_2021B 90

1 81_2022A 50

Course
course_code course_name
COSC2081 Programming 01

COSC2451 Programming Techniques

COSC2539 Security in Comp. and IT

ISYS3414 Practical Database Concepts

COSC2083 Introduction to IT

Class
class_code course semester year lecturer
81_2022A COSC2081 1 2022 3

51_2021C COSC2451 3 2021 1

39_2021B COSC2539 2 2021 2

14_2022A ISYS3414 1 2022 1

14_2021B ISYS3414 2 2021 4

Write SQL queries for the following question.

1. Create the table "Student". (03 Marks)


2. Add a new course "System Development (COMP1845)". (03 Marks)
3. List all lecturers whose name contains the word “Nguyen”. Show Lecturer ID and
Name. (04 Marks)
4. Calculate GPA (average grade) of each student, ordered by GPA from high to low.
Show Student ID and GPA. (05 Marks)
5. Find the average grade of each class. Show Class Code and Average Grade. (05
Marks)
6. List the lecturers’ name and the number of classes that they have taught, ordered
alphabetically by lecturers’ name. (05 Makrs)

You might also like