Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert the following SQL queries to Relational Algebra: SELECT DISTINCT S.Sname FROM Student S, Class C, Enrolled E, Faculty F WHERE S.snum = E.snum AND

Convert the following SQL queries to Relational Algebra:

SELECT DISTINCT S.Sname FROM Student S, Class C, Enrolled E, Faculty F WHERE S.snum = E.snum AND E.cname = C.name AND C.fid = F.fid AND F.fhame = I.Teach AND S.level = JR

SELECT MAX(S.age) FROM Student S WHERE (S.major = History) OR S.num IN (SELECT E.snum FROM Class C, Enrolled E, Faculty F WHERE E.cname - C.name AND C.fid = F.fid AND F.fname = I.Teach )

SELECT C.name FROM Class C WHERE C.room = R128 OR C.name IN (SELECT E.cname FROM Enrolled E GROUP BY E.cname HAVING COUNT (*) >= 5)

SELECT DISTINCT S.sname FROM Student S WHERE S.snum IN (SELECT E1.snum FROM Enrolled El, Enrolled E2, Class Cl, Class C2 WHERE E1.snum = E2.snum AND E1.cname <> E2.cname AND E1.cname = C1.name AND E2.cname = C2.name AND Cl.meets_at = C2.meets_at)

SELECT DISTINCT F.fname FROM Faculty FWHERE NOT EXISTS (( SELECT *FROM Class C )EXCEPT(SELECT C1.roomFROM Class C1WHERE C1.fid = F.fid ))

SELECT DISTINCT F.fname FROM Faculty FWHERE 5 > (SELECT COUNT (E.snum)FROM Class C, Enrolled EWHERE C.name = E.cnameAND C.fid = F.fid)

SELECT S.level, AVG(S.age)FROM Student SGROUP BY S.level

SELECT S.level, AVG(S.age)FROM Student SWHERE S.level <> JRGROUP BY S.level

SELECT F.fname, COUNT(*) AS CourseCountFROM Faculty F, Class CWHERE F.fid = C.fidGROUP BY F.fid, F.fnameHAVING EVERY ( C.room = R128 )

SELECT DISTINCT S.sname FROM Student S WHERE S.snum IN (SELECT E.snumFROM Enrolled E GROUP BY E.snum HAVING COUNT (*) >= ALL (SELECT COUNT (*)FROM Enrolled E2 GROUP BY E2.snum ))

SELECT DISTINCT S.sname FROM Student SWHERE S.snum NOT IN (SELECT E.snumFROM Enrolled E )

SELECT S.age, S.level FROM Student SGROUP BY S.age, S.level,HAVING S.level IN (SELECT S1.levelFROM Student S1WHERE S1.age = S.ageGROUP BY S1.level, S1.ageHAVING COUNT (*) >= ALL (SELECT COUNT (*)FROM Student S2 WHERE s1.age = S2.ageGROUP BY S2.1evel, S2.age))

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

7. Discuss the key features of the learning organization.

Answered: 1 week ago