The title of this post is a bit misleading, but it just goes to show how important it is to ask the right question. The other day, I was working on a challenge homework problem that basically proposed this challenge:

**Use relational algebra to find all schools that offer every class Spanish majors want to take.**

(The actual problem was different, but I don’t want future students to find the answer just by searching for the homework question!) Assume we have two relations:

- Relation S: A list of schools and the classes they offer.
- Relation C: A list of students, their majors, and the classes they want to take.

At first, all I could imagine was that I needed to find every class Spanish majors wanted to take, and then use the results of that query to iterate over the list of schools. I couldn’t think of a different way to approach the problem … until I thought back to the approach I used in the maximum value problem I discussed yesterday. Continue reading “Using Relational Algebra to Select Based on Query Results”