Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

book bookid title Introduction of Algorithms rice total copies 84.66 Database Sy

ID: 3596807 • Letter: B

Question

book bookid title Introduction of Algorithms rice total copies 84.66 Database System Concepts74.99 Stochastic Calculus for Financ41.02 Stochastic Calculus for Finance II 55.22 course title Algorithms DB Organization Advanced DB Organization Math Finance I Math Finance II faculty enroll studentid courseid student studentid facultyid name gpa Tom 3.3 John3.8 Mary 3.0 Kris 3.6 Alex3.5 James 70000 Sarah 60000 ay 80000 Rache 70000 Pau85000 book_ checkout bookid studentid 2017-08-29 2017-09-02 2017-09-07

Explanation / Answer

Query:

delete from course where cid not in(select e.cid from enroll e ,stu s where s.stuid=e.stuid);

output:

0 rows deleted.

Explanation:

inner query returns students those who are enrolled in the various courses.

SQL> select e.cid from enroll e ,stu s where s.stuid=e.stuid ;

output:

CID

----------

1

2

1

3

4

5

6 rows selected.

means every student enrolled at least one course

outer query delete the course those who are not enrolled.

use NOT IN operator to delete course that no one enrolled.

0 rows deleted. because one student registered in each course.