In this lab, you will practise how to use MongoDb queries to find the most suitable restaurant(s) in the provided dataset.
We will use the Example Dataset from the MongoDb official web site.
- Fork and Clone this lab repo to your local.
- Download the dataset and save it as
primer-dataset.json
in your local repo folder. We have included this file in your.gitignore
already so it won't be pushed to your own github repo. - Make sure your
mongod
is running (if not, run it now!). - Run the following command in your repo directory:
mongoimport --db test --collection restaurants --drop --file primer-dataset.json
- A successful import will insert all 25359 entries in your DB.
- Write a MongoDB query for each of the scenarios described in the following sections.
- Collect all your queries in a file called
queries.js
. - Push
queries.js
to your repo. - Submit a pull request to the project repo.
Read the documentation. Try some simple queries first to get an idea how to use it. Use Robomongo write and test your queries.
- List out all available
cuisine
from the whole dataset and sort them in alphabetical order (Hint: read this). - Find out all available
cuisine
from the restaurants that are located onCross Bay Boulevard
and whose address uses zip code11414
. - Find the name and address of the
Steak House
owned by your WDI-HK-10 instructor (Hint: You may want to use regular expression).
- List out the name of all restaurants which contain the word
Pizza
in the cuisine but DO NOT contain the wordPizza
orPizzeria
in the restaurant name (Hint: use regular expression). - List out the name of all straight A (i.e. the restaurant has only received
A
grade ever) restaurants which contain the wordPizza
in thecuisine
and are located in theQueens
borough (Hint: you may want to first find out how many available grade values we have in the entire dataset).
- You are hungry and feel like having a hamburger. Find the number of restaurants listed
Hamburgers
as their main cuisine. - Geez, there are way too many of them. Let's narrow down our search. You are in Manhattan right now so let's find how many restaurants listed
Hamburgers
as their maincuisine
in theManhattan
borough. - Let's have something nice and get rid of the
McDonald's
in the results. Find how many restaurants listedHamburgers
as their maincuisine
inManhattan
and exclude allMcdonald's
(Note: In the data set, McDonald's was presented in inconsistent ways, e.g.McDonald's
andMcDonald'S
. So please use the regular expression/McDonald/
in your query). - Hmm... we are getting closer. Let's also get rid of
Burger King
as well. - There are still plenty of choices. Maybe you should just pick one closer to your home. Find out the list of
distinct
street
based on the results of Question 4. - Alright, you are just a block away from
Pearl Street
. Find thename
of theHamburger
restaurant (i.e. your query should return the name of the restaurant only) onPearl Street
. Your query should now yield exactly one restaurant. What is it? (Submit the query and also the name of the restaurant as a comment)
- Find the name of the restaurants which listed
Japanese
as their main cuisine and have exactly 9grades
.