Write the following questions as queries in Relational Algebra. Use only the ope
ID: 3749564 • Letter: W
Question
Write the following questions as queries in Relational Algebra. Use only the operators discussed in class (select, project, Cartesian product, join, union, intersection, set dierence and renaming). Type your answers. If you can’t nd Greek letters in your word processor, you can simply write out the operator, all uppercase (i.e. ’SELECT’). Please use renaming consistently if it is needed.
Assume a database with schema:
ACTOR(name,age,address,nationality)
MOVIE(title,year,budget,director-name,studio)
APPEARS(name,title,salary)
where the table ACTOR contains information about actors and actresses, and name is the primary key; MOVIE contains information about movies (their title, the year they were made, their budget, the name of the person who directed the movie and the studio who produced it) and title is the primary key; and APPEARS tells us which actor appeared in which movie (so name and title are foreign keys in APPEARS), and how much s/he was paid for acting in the movie. Note that an actor may have appeared in several movies, and a movie may have several actors appearing on it; the key of APPEARS is (name,title).
(b) ) List pairs of actors names that have appeared together in some movie. That is, list pairs (name1,name2) whenever there is some movie ’m’ such that both ’name1’ and ’name2’ appeared in movie ’m’.
Explanation / Answer
Answer:
Below are the example tables created as per the query :
Movie
Queires For Initial Naming:
Name1 = Name(Title=Spider (Appear) ^ Salary=1000 (Appear))
Name2 = Name(Title=Spider (Appear) ^ Salary=1200 (Appear))
Name3 = Name(Title=Rambo (Appear) ^ Salary=1000 (Appear))
Name4 = Name(Title=Rambo (Appear) ^ Salary=1200 (Appear))
Name5 = Name(Title=Avatar (Appear) ^ Salary=900 (Appear))
Name6 = Name(Title=Avatar (Appear) ^ Salary=1100(Appear))
Name7 = Name(Title=Tiger (Appear) ^ Salary=900 (Appear))
Name8 = Name(Title=Tiger (Appear) ^ Salary=1100 (Appear))
Forming Pair Tables:
Pairs1 = Name1 * Name2
Pairs2 = Name3 * Name4
Pairs3 = Name5 * Name6
Pairs4 = Name7 * Name8
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.