M001: MongoDB Basics
Chapter 1: Introduction
Lab 1.1: Install Compass and Connect
Problem:
If you haven't downloaded Compass yet then please go back to this lecture Connecting to MongoDB Using Compass in Chapter 0 and follow the instructions mentioned there for downloading Compass and connecting to the class Atlas cluster.
If you have already downloaded Compass then please use this connection string for connecting to the class Atlas cluster :
mongodb+srv://m001-student:m001-mongodb-basics@cluster0-jxeqq.mongodb.net/test
- Once connected, navigate to the Schema tab in Compass and hit Analyze Schema and answer the following question.
Question:
Which of the following field names appear in documents in the movies collection of the video database. Check all that apply.
Lab 1.2: Determine the Value Type, Part 1
Problem:
Lab 1.4: Determine the Value Type, Part 3
Problem:
Lab 1.5: Scavenger Hunt, Part 1
Problem:
Lab 2.1: How Many Comedies?
Problem:
- If you have not already loaded the video.movieDetails collection, please review the lesson "Loading Data into Your Sandbox Cluster" for a tutorial. Then, use the script, loadMovieDetailsDataset.js, provided in the handouts for the lesson, "Connecting to an Atlas Cluster from the Mongo Shell" to load the movieDetails collection.
- Use Compass to connect to your sandbox cluster.
- In Compass, view the video.movieDetails collection and apply the filter {genres: "Comedy"}.
How many documents in video.movieDetails match the filter {genres: "Comedy"}?
Lab 2.2: How Many Inserted?
Problem:
If the collection video.myMovies is currently empty, how many documents would be inserted by the following call to insertMany().
Lab 2.4: Queries on Array Fields, Part 1
Problem:
Explore the movieDetails collection that you loaded into your Atlas sandbox cluster and then issue a query to answer the following question. How many movies in the movieDetails collection list "Family" among its genres?
You will find the count() method useful in answering this question using the mongo shell.
Lab 2.5: Queries on Array Fields, Part 2
Problem:
Explore the movieDetails collection that you loaded into your Atlas sandbox cluster and then issue a query to answer the following question. How many movies in the movieDetails collection list "Western" second among its genres?
You will find the count() method useful in answering this question using the mongo shell.
Lab 2.6: Update Operators
Problem:
To work on this lab, you need to connect to the sandbox cluster in which you have imported the video.movieDetails collection.
Suppose you wish to update the value of the plot field for one document in our movieDetails collection to correct a typo. Which of the following update operators and modifiers would you need to use to do this?
Chapter 3: Deeper Dive into the MongoDB Query Language
Challenge Problem: Single Value in an Array of Integers
Solution: for shell => db.score.find({results:{$elemMatch: {$gte: 70},{$lte: 80 }}})
For compass =>{results: {$elemMatch: {"score": {$gte: 70}, "score": {$lte: 80 }}}}
Final Exam
Final Exam: Question 1
Problem:
Connect to our class Atlas cluster from Compass and view the citibike.trips collection.
Use the schema view and any filters you feel are necessary to determine the range of values for the usertype field. Which of the following are values found in this collection for the field usertype?
Solution:
Final Exam: Question 2
Problem:
Connect to our class Atlas cluster from Compass and view the 100YWeatherSmall.data collection.
Using the Schema view, explore the wind field. The wind field has the value type of document. Which of the following best describes the schema of this embedded document?
Final Exam: Question 3
Problem:
Connect to our class Atlas cluster from Compass and view the 100YWeatherSmall.data collection.
What is the value type of the "wind.speed.rate" field?
Final Exam: Question 4
Problem:
Please connect to our class Atlas cluster and view the citibike database.
How many documents in the citibike.trips collection have the key tripduration set to null? Ignore any documents that do not contain the tripduration key.
Final Exam: Question 5
Final Exam: Question 6
Problem:
Please connect to our class Atlas cluster from the mongo shell or Compass and view the video.movies collection.
How many movies match the following criteria? - The cast includes either of the following actors: "Jack Nicholson", "John Huston". - The viewerRating is greater than 7. - The mpaaRating is "R".
No comments:
Post a Comment