Movies.ShowID

Sample Problems

Relational Algebra Queries with TVMovies
CSE4701
ANN.1
Third Page Shows Tuples
CSE4701
ANN.2
Third Page Shows Tuples
CSE4701
ANN.3
Let’s Look at Problem 1a from Fall 2015

CSE4701 

Find the names (Last and First) and State of All
persons that were in a Movie in 1997
What are Tables that we Need?
 Movies to get 1997 Movies by Year
 MovieRoles to Find the PersonID for all Actors
in those Movies
 Person to Use to Find Last/First Names
Identify Needed Info by Table and How Link
ANN.4
Problem 1a
Find the names (Last and First) and State of All
persons that were in a Movie in 1997
Find the Movies in 1997

CSE4701 
Movies1997(ShowID)
= ShowID (
Year=1997 (Movies))
Find the Actors in those Movies by Movie Roles

MovieActors(PersonID) =
PersonID(
Link those Actors to the Person Table

1a.Answer
Movies1997.ShowID=MovieRoles.ShowID (Movies1997 x MovieRoles))
=
Lname,Fname,State(Person.PersonID
= AllActors.PersonID(Person x MovieActors))
ANN.5
Problem 1b
Find the names (Last and First) and State of All
persons that were in a TV show in 1987
Find the Movies in 1977

CSE4701 
Shows1987(ShowID)
= ShowID (
Year=1987 (TVShows))
Find the Actors in those TV show by TV Roles

TVActors(PersonID) =
PersonID(
Link those Actors to the Person Table

1b.Answer
Shows198.ShowID=TVRoles.ShowID (Shows1987 x TVRoles))
=
Lname,Fname,State(Person.PersonID
= AllActors.PersonID(Person x TVActors))
ANN.6
Problem 1c and 1d

All persons that were in either a Movie in 1997 or a
TV show in 1987
CSE4701
AllActors(PersonID) = 1a.Answer 

1b.Answer
All persons that were in both a Movie in 1997 and
a TV show in 1987
AllActors(PersonID) = 1a.Answer 
1b.Answer
ANN.7
Problem 2

CSE4701

Find the last names (Last/First Name) of the directors for
all Movies &TV Shows that have the same name (TV Show
&Movie have same names
IDs for Movies and TVShows with Same Names
MovieIDs(ShowID) = Movies.ShowID
( MovieName = ShowName (Movies x TVShows))
TVShowIDs(ShowID) = TVShows.ShowID
( MovieName = ShowName (Movies x TVShows))

Names of Directors
MovieDirs(PersonID) = PersonID
( Movies.ShowID = MovieDirectors.ShowID (MovieIDs x
MovieDirectors))
TVDirs(PersonID)
PersonID
 Join the =result
( TV.ShowID = TVDirectors.ShowID (TVShowIDs x TVDirectors))
Answer = Lname,FName (  Person.PersonID = PersonID (Person x
(MovieDirs  TVDirs)))
ANN.8
Problem 3

CSE4701

Find the names (Last name and First Name) of all actors
and their roles for “Friends” for Episodes 11 to 25
Friends TVShow
Friends(ShowID) = ShowID (

ShowName=Friends
(TVShows))
Actors and Roles for Episodes 11 to 25
ActorsandRoles(PersonID, RoleID) = PersonID, RoleID
((TVRoles.ShowID=Friends.ShowID)and(EpisodeID>10andEpisodeId<26)
(TVRoles x Friends))
RoleNames (PersonID, RLName, RFName) = PersonID,RLName,RFName
( ActorsandRoles.RoleID=Roles.RoleID (ActorsandRoles x
Roles))

Answer
Answer = Lname,Fname,RLName,RFName
( Person.PersonID = RoleNames.PersonID (Person x RoleNames))
ANN.9
Problem 4

CSE4701

Find the names (Last name and First Name) that
played the same Role in a TV and a Movie who
won an Emmy for the TV role but did not win an
Oscar for the Movie role.
Persons that won Emmys
TVwithEmmy = PersonID, RLName, RFName
( ( EmmyFlag=True TVRoles) *

Roles)
Persons that didn’t win Oscars
MovieNoOscar = PersonID, RLName, RFName
( ( OscarFlag=False MovieRoles) *

RoleID,ShowID
RoleID,ShowID
Roles)
Join the result
Answer = Lname,Fname,RLName,RFName
( Person.PersonID = RoleNames.PersonID(Person x RoleNames))
ANN.10
Problem 5

5. Find the names of all Shows or Movies that
have won an Emmy (TV Show) or Oscar (Movie).
CSE4701
WonEmmys = ShowName (
NumEmmy>0
WonOscars = MovieName (
Answer =
(TVShows)
NumOscar>0
(Movies))
WonEmmys  WonOscars
ANN.11