[prev] 37 [next]

Mapping SQL to Relational Algebra (cont)

More complex example:

select   distinct s.code
from     Course c, Subject s, Enrolment e
where    c.id = e.course and c.subject = s.id
group by s.id  having count(*) > 100;

can be translated to the relational algebra expression

Uniq(Proj[code](
    GroupSelect[groupSize>100](
        GroupBy[s.id] (
            Enrolment ⋈ Course ⋈ Subjects
))))