Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question about SQL and not exists clause Given this schema: Professors (pid, pname, dept, ext.). Students (sid, sname, major-dept, year) Courses (cid, cname, dept, credithours)

Question about SQL and "not exists" clause

Given this schema:

Professors (pid, pname, dept, ext.).

Students (sid, sname, major-dept, year)

Courses (cid, cname, dept, credithours)

Enrollment (sem-year, sid, cid, grade)

Teach (pid, cid, sem-year, class_size)

Q: sid's of students enrolled in "spring 2017" every 3 credit hr course offered by "cs" department:

Answer:

Select sid from Students s where not exists (

(select c.cid from Courses c where c.dept= CS and c.credithours= 3)

except

(select e.cid from Enrollment e where e.sid=s.sid and sem-year = Spring2017))

I need an in-depth explanation for why/how this works, as well as an explanation of how the not exists clause works.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

More Books

Students also viewed these Databases questions