0

Can someone help me in writing the following query to relational algebra, I am studying DBMS and I am stuck on this exercise.

Query:

SELECT a.name, d.name. d.grade
FROM student a, enrolled i, class d
WHERE a.id= i.student_id
AND i.disc_id = d.id

Thanks

1

This line represents a cartesian product of 3 tables:

FROM student a, enrolled i, class d

After creating a cartesian product you filter out rows that match the predicate.

WHERE a.id= i.student_id
AND i.disc_id = d.id

If you look closer at this query it is equivalent to:

  SELECT a.name, d.name. d.grade
    FROM student a
      JOIN enrolled i ON a.id= i.student_id
      JOIN class d ON i.disc_id = d.id

Maybe you should analyze the second query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.