Question
Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer,
Student(snum: integer, sname: string, major: string, level: string, age: integer) Class(name: string, meets at: string, room: string, fid: integer) Enrolled(snum: integer, cname: string) Faculty(fid: integer, fname: string, deptid: integer) The meaning of these relations is straightforward; for example, Enrolled has one record per student-class pair such that the student is enrolled in the class.
Write the following queries in relational algebra NOT SQL. No duplicates should be printed in any of the answers. What is the relational algebra from the question below. I already have the SQL and need it in relational algebra.
5. Find the names of faculty members who teach in every room in which some class is taught.
SELECT DISTINCT F.fname
FROM Faculty F
WHERE NOT EXISTS ( (SELECT *
FROM Class C)
EXCEPT
( SELECT C1.room
FROM Class C1
WHERE C1.fid = F.fid));
6. Find the names of faculty members for whom the combined enrollment of the courses that they teach is less than five.
SELECT DISTINCT F.fname
FROM Faculty F
WHERE 5 > (SELECT COUNT (E.snum)
FROM Class C, Enrolled E
WHERE C.name = E.cname
AND C.fid = F.fid);
7. For each level, print the level and the average age of students for that level.
SELECT S.level, AVG(S.age)
FROM Student S
GROUP BY S.level;
8. For all levels except JR, print the level and the average age of students for that level.
SELECT S.level, AVG(S.age)
FROM Student S
WHERE S.level <> JR
GROUP BY S.level;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started