Hint on assignment on $lookup

Can someone tell what columns to use as joining criteria between air_airlines and air_routes ?

Hi,

The fields you should use to perform the join are the name in the airline subdocument (air_routes collection) and airlines in the air_alliances collection.

Hope this helps.

José Carlos

Just a sanity check: if you take, for example, KLM from the Sky Team air_alliances collection, and try to find it using name as a filter in air_routes, you won’t find anything, since KLM is named “KLM Royal Dutch Airlines” in the routes collection. So, is data consistent between both collections? I don’t think using “name” from air_routes and “airlines” from air_alliances will produce an accurate output.

I’m asking this because if you filter only 747 or 380 routes in the air_routes collection, and then count the routes grouped by airline name, you will see that KLM Royal Dutch Airlines is the top one with 11 routes, but it won’t count towards the Sky Team alliance number of routes, if I use the name field to the lookup stage.

Hi,

You are right, we are aware of those inconsistencies. If I recall, they are intended for other course. To get the right answer for this homework, just use the name to perform the join.

José Carlos

Thanks for the feedback Jose Carlos. I found out my solution works regardless of the airline naming problem. I was inverting the lookup local/foreign fields, I thought local was related to the from collection, but I figured it’s the other way around (foreign is related to the from collection, local is related to the aggregation command collection). After inverting the fields, it worked like a charm and I could solve the lab.

Regards