Here DIFFERENCE is the set difference operator extended to work with any two pairs of relations. This extended DIFFERENCE is generally called an ANTIJOIN, you can look up its definition here

Question 1: Where and when can we see the movie “Mad Max...”?
Solution 1: DROP(FILTER(Room,movieTitle="Mad Max"),MovieTitle)

Question 2: What are the movies directed by Welles?
Solution 2: DROP(DROP(FILTER(Movie,Director="Welles"), Director), Actor)

Question 3:
Who are the actors of "Ran"?
Solution 3: DROP(DROP(FILTER(Movie,MovieTitle="Ran"),Director),MovieTitle)

Question 4: Where can we see a movie in which Signoret plays?
Solution 4:
    moviesWithS = DROP(DROP(FILTER(Movie,Actor="Signoret"),Actor),Director)
    whereMovie = RENAME(DROP(Movie,Time),MovieTitle,MovieTitleBis)
    DROP(FILTER(PRODUCT(moviesWithS,whereMovie), movieTitle=movieTitleBis),            [MovieTitle,MovieTitleBis])

Question 5: Among the actors who produced at least one movie?
Solution 5:
    actors = DROP(DROP(Movie,MovieTitle),Director)
    producers = DROP(Producers,MovieTitle)
Question 6:
Among the actors who directed a movie that they played in?
Solution 6:
Question 7: Who plays in one (or more) movie from Varda?
Solution 7: DROP(FILTER(Movie,Director="Varda"),[MovieTitle,Director])

Question 8: Who are the actors playing in all the films from Chloé Zhao?
Solution 8:
    ZhaoMovies = DROP(FILTER(Movie,Director="Zhao"),[Director,Actor])
    allPairsA_ZM = PRODUCT(actors,ZhaoMovies)
    missingPairs = DIFFERENCE(allPairsA_ZM,Movies)
    actorsNotInAllZhao = DIFFERENCE(actors, missingPairs)
    actorsInAllZhao = DIFFERENCE(actors,actorsNotInAllZhao)
Question 9:
Who produces all the movies from Kurosawa?
Solution 9:
    KurosawaMovies = DROP(FILTER(Movie,Director="Zhao"),[Director,Actor])
    AllPairsKM_P = PRODUCT(producers,KurosawaMovies)
    missingPairs = DIFFERENCE(AllPairsKM_P,Producer)
    producersNotInAllK = DIFFERENCE(Producer,missingPairs)
Question 10:
Who are the spectators watching all the movies?
Solution 10:
    movieNames = DROP(Movie,[Director,Actor])
    spectators = DROP(Seen,MovieTitle)
    allPairs_ms = PRODUCT(movieNames,spectators)
    missingPairs = DIFFERENCE(allPairs_ms, Seen)
    DIFFERENCE(spectators, missingPairs)
Question 11:
Among the spectators, who likes all the movies they see?
Solution 11:

Question 12:
Where can we see Adèle Haenel after 16:00?
Solution 12:
    moviesRoomAfter16 = DROP(FILTER(Room,time>=16:00),Time)
    moviesWithHaenel = RENAME(DROP(FILTER(Movie,Actor=Haenel),[Director,Actor]),MovieTitle,MovieTitleBis)
Question 13:
What are the movies with no room projecting them?
Solution 13: DIFFERENCE(Movie,Rooms)
Question 14:
Among the producers, who produces a movies shown nowhere?
Solution 14:
Question 15:
Among the producers who saw all the movies they directed?
Solution 15:
    AllPairs_P_M = PRODUCT(movieNames, producers)
    missingPairs = DIFFERENCE(AllPairs_P_M,Producer)
Question 16:
Among the spectators, who saw all the movies from Kurosawa
Solution 16:
    moviesK = DROP(FILTER(Movie,Director="Kurosawa"),[Director,Actor])
    allPairs_ms = PRODUCT(moviesK,spectators)
    missingPairs = DIFFERENCE(allPairs_ms, Seen)
    DIFFERENCE(spectators, missingPairs)

Question 17:
Among the spectators, who liked a movie they did not watch?
Solution 17:
Question 18:
Among the spectators, who liked 0 movies?

Solution 18:  DIFFERENCE(DROP(Seen,MovieTitle),DROP(Like,MovieTitle))

Last modified: Sunday, 19 September 2021, 6:36 PM