Skip to content
Wali Ullah Khan
All analytics work

Analytics project, 2024

Querying a film catalogue in MongoDB

Aggregation pipelines over a document store to answer questions a relational schema makes awkward.

A document database schema visualisation.

Film and viewership data is deeply nested: cast, crew, genres, ratings and regional availability all hang off a title in variable shapes. Flattening that into relational tables loses more than it gains.

This kept the documents intact and did the work in aggregation pipelines, using stages to unwind, group and rank across the nested structure directly.

The point of the exercise was the modelling decision rather than the queries. Knowing when a document store earns its place, and when it is just a slower join, is the transferable part.

Results

  • Aggregation pipelines over nested cast, genre and rating documents
  • Ranking and cohorting without flattening the schema
  • A working case for when a document store is the right call