relational-algebrarelational-division

Database Relational Algebra: How to find actors who have played in ALL movies produced by "Universal Studios"?


Given the following relational schemas, where the primary keys are in bold:

movie(movieName, whenMade);
actor(actorName, age);
studio(studioName, location, movieName);
actsIn(actorName, movieName);

How do you find the list of actors who have played in EVERY movie produced by "Universal Studios"?

My attempt, where ⋈ is natural join:

π actorName ∩ (σ studioName="Universal Studios" studio) ⋈ actsIn

Maybe you are supposed to use Cartesian product and/or division.


Solution

  • Here are the two steps that you should follow:

    1. Write an expression to find the names of movies produced by “Universal Studio” (the result is a relation with a single attribute)

    2. Divide the relation actsIn by the result of the relation obtained at the first step.

    This should give you the expected result (i.e. a relation with the actor names that have played in every movie of the “Universal Studio”).