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

梦想与她 提交于 2020-01-22 03:49:05

问题


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:

π actorName ∩ (σ studioName=“Universal Studios” studio) |><| actsIn, where |><| is the natural join

Are you supposed to use cartesian product and/or division? :\


回答1:


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”).



来源:https://stackoverflow.com/questions/36515705/database-relational-algebra-how-to-find-actors-who-have-played-in-all-movies-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!