HW 3 – Document data stores. MongoDB

(5 points)

  1. Design the data structures based on the analytical tasks (see HW1) that are intended to be solved with MongoDB (primary and alternative 1).
    • The structures must be designed so that the target queries are feasible.
    • Avoid overly nested documents.
      • Denormalize only when it benefits performance; do not create overly deep nesting that complicates queries.
  2. Insert the data into MongoDB using the CSV/JSON generated for the project (see HW0). Use the Base dataset as defined in HW0.
    • Load only what is needed for tasks/comparisons. Do not import unnecessary data.
    • In the .js file, insert several dozen documents directly (if needed, across multiple collections) as examples, placed before any queries.
    • Using a separate, idempotent script, generate and insert the required dataset of the assignment’s target size (see HW0).
  3. Implement and run the queries (see HW1). Create supporting indexes for every analytical query (Note: creating indexes for this task is not mandatory, but is recommended).
    • Use the Aggregation Pipeline; do not use `$where`, server-side JavaScript, or `mapReduce`.
    • Apply appropriate time filters, groupings, and KPIs as required by your HW1 tasks (do not hardcode specific fields like “country/action” if your domain differs).
    • All queries must return a non-empty result on the sample data inserted in the .js file.
  4. Prepare a report and include:
    • the tasks from both HW0 and HW1 related to MongoDB (edited if necessary);
    • the collections creation and sample document-insertion commands, with explanations of why this structure was chosen;
    • the queries used to solve the analytical tasks. For each task, provide:
      • the task number (as in the previous work);
      • the verbal description of the task;
      • the query code with explanations;
      • a screenshot of the query result;
    • the data import script.

Note. If some analytical tasks turn out to be infeasible or meaningless, you may replace them with others and propagate the corresponding changes to the earlier work (HW0/HW1).

Submit to the BRUTE system:

Submit to the NoSQL server (nosql.felk.cvut.cz) the hw3.js file with MongoDB commands with short comments to each query.

mongosh --port 42222 -u $login -p $password $database $file