M001: MongoDB Basics Chapter 1: Introduction 课后习题答案

M001: MongoDB Basics Chapter 1: Introduction 课后习题答案

Lab 1.1: Install Compass and Connect

Problem:
If you have not yet downloaded Compass, please follow these instructions. Then answer the question below.

  1. Please download Compass from the MongoDB Download Center.
  2. Install Compass on your computer from the download.
  3. Launch Compass.

When Compass opens you will see a page titled “Connect to Host”.
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
4. Use the following information to complete this form, but do not click “Connect” yet. Hostname is cluster0-shard-00-00-jxeqq.mongodb.net. Username is m001-student. Password is m001-mongodb-basics.
5. Click “Add to Favorites” so that you can easily connect to our class MongoDB deployment after closing and restarting Compass at some point in the future.
6. Now, click “Connect” and load the databases in the M001 class MongoDB deployment.

Question Which of the following field names appear in documents in the movies collection of the video database. Check all that apply.

Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to the schema view for the movies collection of the video database. Fields are listed in alphabetical order in the schema view and all fields found in the collection are listed in this view. Scroll through the schema view to check each choice to see whether it is present in documents in this collection.

Lab 1.2: Determine the Value Type, Part 1

Problem:
What is the value type of the ts field for documents in the 100YWeatherSmall.data collection?
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to the schema view for the data collection of the 100YWeatherSmall database. Scroll through the schema view to find the ts field. The value type is described immediately below the field name. You should see the following for this field in the Compass schema view. Note that date is listed as the value type for ts.
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案

Lab 1.3: Determine the Value Type, Part 2

Problem:
What is the value type of the airTemperature field for documents in the 100YWeatherSmall.data collection?
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to the schema view for the data collection of the 100YWeatherSmall database. Scroll through the schema view to find the airTemperature field. The value type is described immediately below the field name. You should see the following for this field in the Compass schema view. Note that document is listed as the value type for airTemperature.
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案

Lab 1.4: Determine the Value Type, Part 3

Problem:
What is the value type of the year field for documents in the video.movies collection?
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to the schema view for the movies collection of the video database. Scroll through the schema view to find the year field. The value type is described immediately below the field name. You should see the following for this field in the Compass schema view. Note that int32 is listed as the value type for year.

Lab 1.5: Scavenger Hunt, Part 1

Problem:
How many movies in the video collection were directed by Patty Jenkins. Stated more precisely, how many documents in the video.movies collection have a value of “Patty Jenkins” for the director field?
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to either the schema view or the documents view for the movies collection of the video database. To get the correct answer, you need to enter the following query in the filter form field:

{“director”: “Patty Jenkins”}

Lab 1.6: Scavenger Hunt, Part 2

Problem:
How many documents in the citibike.trips collection have a tripduration that is greater than or equal to 60 and less than 65?
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to either the schema view or the documents view for the citibike.trips collection. To get the correct answer, you need to enter the following query in the filter form field:

{“tripduration”: {“gte":60,"lt”: 65}}

Lab 1.7: Scavenger Hunt, Part 3

Problem:
Based on our shipwrecks dataset, how many shipwrecks lay off the coast of Cancun, Mexico? Choose the answer that best describes the number of shipwrecks you are able to find using Compass.
Answer:
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案
detailed answer:
In Compass, navigate to either the schema view or the documents view for the ships.shipwrecks collection. To get the correct answer, locate Cancun, Mexico on the map for the coordinates field. Click on the name, “Cancun” on the map, press the shift key on your keyboard and drag your mouse to a radius that encompasses the coast of Cancun. Click the “APPLY” button near the filter form field. I found three shipwrecks.
M001: MongoDB Basics Chapter 1: Introduction 课后习题答案