You are on page 1of 3

T1 – L2 Basic Setting and simple query

1. Visit MongoDB Atlas with a browser and login. After that visit collections.
2. Go to collections
3. Fill in the following table:
How many database in the sample cluster? Name all of these.

4. Visit the database named “sample_training”. How many collections within this database?

5. Take a look into “sample_training.routes”. How to query “HKG” within “src_airport”?

6. Follow the steps below.


a. Create a new database named “mongo_movie”
b. Insert the following documents:
title : Fight Club
writer : Chuck Palahniuk
year : 1999
actors : [
Brad Pitt
Edward Norton
]

title : Pulp Fiction


writer : Quentin Tarantino
year : 1994
actors : [
John Travolta
Uma Thurman
]

title : Inglorious Basterds


writer : Quentin Tarantino
year : 2009
actors : [
Brad Pitt
Diane Kruger
Eli Roth
]

title : The Hobbit: An Unexpected Journey


writer : J.R.R. Tolkein
year : 2012
franchise : The Hobbit

title : The Hobbit: The Desolation of Smaug


writer : J.R.R. Tolkein
year : 2013
franchise : The Hobbit

title : The Hobbit: The Battle of the Five Armies


writer : J.R.R. Tolkein
year : 2012
franchise : The Hobbit
synopsis : Bilbo and Company are forced to engage in a war against an array
of combatants and keep the Lonely Mountain from falling into the hands of a
rising darkness.

title : Pee Wee Herman's Big Adventure

title : Avatar

c. query the movies collection to


(i) get all documents

(ii) get all documents with writer set to "Quentin Tarantino"

(iii) get all documents where actors include "Brad Pitt"

(iv) get all documents with franchise set to "The Hobbit"


Home Practice
Follow the instruction from https://docs.atlas.mongodb.com/compass-connection, download
MongoDB Compass from MongoDB and try to connect to the sample cluster through MongoDB
Compass.
Make sure the following settings are ready:
1. Make sure you have created a database user with “readWriteAnyDatabase” roles
2. Make sure you have granted the white list in the network access.
3. If you are behind a firewall, make sure that port 27017 is available for connection.
You can dump a screen here once you are connected to the cluster with Compass here.

You might also like