M121 chapter 4 lab facets. No correct answers, detailed answer is incorrect

question:
How many movies are in both the top ten highest rated movies according to the imdb.rating and the metacritic fields? We should get these results with exactly one access to the database.

Detailed answer from the course assumes that metacritic field should be mandatory in top 10 imdb.rating. But there is no word about that in the question. If we take top 10 with imdb.rating field, there will be extra movies without defined metacritic field.

Think about it. Can you be in both list if you do not have a rating for one of the rating system?

The ‘both’ here is interpreted as mathematical set intersection of two arrays: top 10 movies for “imdb.rating”, and top 10 movies for metacritic. There is no any explicit written requirement, that metacritic and imdb.rating fields should be mandatory for both ratings, otherwise it would be written as:

How many movies are in both the top ten highest rated with both fields mandatory movies according to the imdb.rating and the metacritic fields? We should get these results with exactly one access to the database.

Actually, you don’t need to know that. this is a two-steps process:

  • find top-10 in imdb ratings and also find top-10 in metacritic
  • and then compare two lists and extract movies that are in both list.

the process automatically eliminates null fields as it is just a list comparison in the second step.

the first step will get you 10 non-null entries in each list if you have more than enough movies. in fact, you won’t get any null entries in those lists even when imdb/metacritic fields are missing. for example, if there are only 7 documents with imdb fields, you will get only 7 results, not 10 results with 3 nulls.

you just need to figure out how to create two lists in one query, and then compare those lists again in the same query.