MongoDB document model
Exercise 1: Querying embedded documents
Create a database
Create a Collection
Insert the data: https://github.com/nicklasdean/data/blob/main/concerts-embedded.json
Find all concerts in Copenhagen
5 results returned
Find all concerts that are on sale
6 results returned
Find all concerts where the artist genre is pop
2 results returned
Find all concerts with any ticket price cheaper than 600 dkk
3 results returned
Find all concerts in Copenhagen with a ticket price over 900 dkk
3 results returned
Find all pop concerts that are on sale currently
2 results returned
Exercise 2: Querying referenced documents
Create a database, e.g. concerts_db.
Create three collections: artists, venues, and events.
Insert the data:
https://github.com/nicklasdean/data/blob/main/artists.json
https://github.com/nicklasdean/data/blob/main/venues
https://github.com/nicklasdean/data/blob/main/events.json
Find all events by Taylor Swift
1 result returned
Find all events with an age limit greather than or equal to 18
6 results returned
Find all events in Copenhagen venues
5 results returned
Find all "on sale" events at Royal Arena
3 results returned
Data-model design exercise:
Scenario
We are building a cooking app. The app shows a single recipe page with everything in one place: ingredients, steps, timings, and per-step tips.
Users can add recipes to meal-lists like a playlist on spotify (breakfeast, lunch, dinner).
What do we know: The constraints.
The UI fetches the a full recipe- view at once (one view).
Recipes and steps are small and bounded (≈10–30 ingredients; 5–20 steps).
Ingredients and steps are edited with the recipe, not independently.
We imagine 100.000+ users and therefore much more weekly meal lists.
Design a MongoDB data model that satisfies the scenario and constraints.
You should create an example of the collection(s) and documents.
Explain the embed/reference choices.
Recipe
Inspiration view: https://www.valdemarsro.dk/kartoffelsuppe/

What data we know will be collected
Core data
Recipe titledescriptionchef_idtagsservingstotal_time_min
ingredients
nameqtyunitnote
steps
texttiptimer_sec
Meal list
list_typetitle
User
nameemail
Questions:
How should a meal list reference/embed/be embedded by a User?
How should a user reference/embed/be embedded by a Meal list?
Last updated