Boston University

CAS CS 460/660 - Introduction To Database Systems

PA3: NoSQL Databases

This is for both CS 460 and CS 660 students

Due on: Tuesday, Dec 12, 2017 at 11:59PM. 

1. Introduction

In this assignment, you will use a NoSQL database system  called MongoDB. 

More about MongoDB and JSON you can find here and here.

2. Setup the Database

1. Download and install MongoDB (see more  here or here.)

2. Download a  restaurants  dataset at

3. Use mongoimport to import  the restaurants dataset into MongoDB. 

(use something like this: 

    > mongoimport --db test --collection restaurants --drop --file primer-dataset.json

You may need to specify the full directory of the file )

You can find more instructions here .

Now you are ready to start the project. Notice that the dataset contains information about restaurants in New York City.

3. Queries in MongoDB

After importing the data, write queries in MongoDB to answer the following questions (try to use aggregation pipelines when possible): 

(1) Find the restaurant ID of “Caffe Dante”.

(2) Find all restaurants whose name has “Ice Cream” in it, return only the restaurant’s ids and names.

 (3) Find the names of all restaurants that serve either Italian or American cuisine and are located in the Brooklyn borough.

(4) Return the list of boroughs ranked by the number of American restaurants in it. That is, for each borough, find how many restaurants serve American cuisine and print the borough and the number of such restaurants sorted by this number.

 (5) Find the top 5 American restaurants in Manhattan that have the highest total score. Return for each restaurant the restaurants’ name and the total score.    Hint: You can use “$unwind”.

(6) Consider a rectangle area on the location field, in which the vertices are [ -74 , 40.5 ] , [ -74 , 40.7 ] , [ -73.5 , 40.5 ] and [ -73.5 , 40.7 ]. Find the number of restaurants in this area that have received a grade  score (at least one) more than 50. 

Hint: Use the $geoWithin and $box.

 Write down your queries. 

4. Submission instructions

Create a file that contains the queries in MongoDB and your comments (if any) but NOT the results of the queries. 

We accept only Text or PDF files.

You should turn in your file by Tuesday, Dec 12, 2017 at 11:59PM via gsubmit.

Please include your username in the name of your PA3 report. For example: "bob_pa3.pdf".