Reputation: 149
I have to translate an SQL query to relational algebra in a specific way but im not sure if my answer is a correct one.
Database
Students: (studentID, firstname, familyname, address, borough)
Entries: (studentID, examID< result)
Exams: (examID, examName, qualification, board, date)
SQL query
SELECT studentID
FROM Students s, Entries e, Exams x
WHERE s.studentID = e.studentID AND e.examID = x.examID AND
s.borough='Haringey' AND e.result = 'pass' AND x.examName='Latin'
I have to re-express this query in relational algebra where the joins are performed on the tables after the tables have been reduced by the selection operators
my answer
PROJECTstudentID(SELECTs.borough='Haringey'(Students)) EQUIJOIN s.studentID=e.studentID((SELECTe.result='pass'(Entries)) EQUIJOIN e.examID=x.examID (SELECTx.examName='Latin'(Exams)))
Upvotes: 0
Views: 270
Reputation: 27424
Your query is correct. You have “pushed” all the select operation correctly. Note that you could also project the result of each select to the minimun number of attributes required by the following operators.
Upvotes: 1