Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have written the queries in SQL but I don't know how to convert it to RA, TRC, DRC, QBE. If the query CAN'T be

I have written the queries in SQL but I don't know how to convert it to RA, TRC, DRC, QBE. If the query CAN'T be converted to the appropriate RA/TRC/DRC/QBE - please mention the reason too! Here's the schema :

Students(snum, sname, major, standing, age, gpa)

Faculty(fid, fname, deptid)

Courses(cnum, cname, course_level, credits)

Offerings(onum, cnum, day, starttime, endtime, room, max_occupancy, fid)

Enrolled(snum, onum) PLEASE ANSWER THE FOLLOWING QUESTIONS :

1. (RA, TRC, DRC, QBE) Write a query which displays the student names and the courses (course name) which the student has taken. select s.sname, c.cname from Students s join Enrolled e on s.snum = e.snum join Offerings o on e.onum = o.onum join Courses c on o.cnum = c.cnum;

2. (RA, TRC, DRC, QBE) Find the names of students who are not enrolled in any course. select s.sname from Students s where NOT EXISTS (select null from Enrolled e where s.snum = e.snum);

3. (RA, TRC, DRC, QBE) Find the courses taught by faculty from more than two departments. select temp.cname from (select c.cname, count(f.deptid) as Count from Courses c join Offerings o on c.cnum = o.cnum join Faculty f on o.fid = f.fid having count(f.deptid) > 2 group by c.cname) temp;

4. (DRC, QBE) Find the name of the course with the highest total maximum occupancy (over all course offerings). select temp.cname from (select c.cname, SUM(o.max_occupancy) as Sum, rank() over (order by SUM(o.max_occupancy) DESC) as Rnk from Courses c join Offerings o on c.cnum = o.cnum group by c.cname) temp where rnk <= 1;

5. (RA, TRC) Find the courses that have been taken by all students. select c.cname, c.cnum from Courses c join Offerings o on c.cnum = o.cnum join Enrolled e on o.onum = e.onum join Students s on e.snum = s.snum having count(*) = (select count(*) from Students) group by c.cname, c.cnum;

6. (RA, DRC) Find students with a GPA > 3.0 that are taking exactly two courses. select s.sname, s.snum from Students s join Enrolled e on s.snum = e.snum join Offerings o on e.onum = o.onum where s.gpa > 3 having Count(o.cnum) = 2 group by s.sname, s.snum;

7. (TRC, QBE) Find courses taught by only one faculty member. select c.cname, c.cnum from Courses c join Offerings o on c.cnum = o.cnum join Faculty f on o.fid = f.fid having count(DISTINCT o.fid) = 1 group by c.cname, c.cnum;

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

Students also viewed these Databases questions