Database questions: Student table, Course Selection table, course schedule, course schedule
There are three basic tables in the teaching database:
Student table S (S #, SNAME, AGE, SEX). Its Attributes indicate the student's student ID, name, AGE, and gender. The course selection table SC (S #, C #, GRADE ), the attributes indicate the student's student ID, course number, and score. The curriculum C (C #, CNAME, TEACHER) indicates the course number, course name, and instructor name. The following questions are all about the above three basic tables.
(1) write an SQL statement to retrieve the course number of all courses selected by female students.
Select C #
From S, SC
Where S.S # = SC. S # and S. SEX = 'femal'
(2) write the following SQL statement for the insert operation: insert the average score of each course in the SC table into another existing table SC _C (C #, CNAME, AVG_GRADE, AVG_GRADE indicates the average score of each course.
Insert into SC _C
Select SC. C #, C. CNAME, AVG (SC. GRADE)
From SC, C
Group by C #
(3) try to write the following SQL statement for deletion: Delete the tuples of WU's female course selection from the SC table.
Delete from SC
Where S # in
(Select S # from S where SEX = 'female ')
And C # in
(Select C # from C where TEACHER = 'wu ')