$35
HW-6 MongoDB
CSCI 3287: Design and Analysis of Data Systems Page 2
Overview
• Assignment points: 10 points or 10% toward your final grade.
• All Questions are equally weighted (10 question for total of 10 points).
• Submission: submit Mongo SQL scripts and output (result set) in Canvas in pdf or word doc.
• Make sure to mark your answers with the question number.
• This is open book exam, and any kind of resource materials are allowed.
This assignment will give you hands-on practice in working with the MongoDB “NoSQL”
database software.
Objectives
1. Download and install MongoDB.
2. Create a MongoDB database to store a collection of documents.
3. Load a large amount of document-based data into the collection.
4. Query the document collection to research a topic and answer questions.
Installations
Visit the MongoDB Compass installation guide at
https://www.mongodb.com/docs/compass/current/install/ . Choose the installation package that matches
your operating system, and then proceed to follow the provided installation instructions.
Write MongoDB SQL scripts for below questions:
NOTE 1:
Before addressing the questions, please make sure you have set up a database named 'CSCI3287' in
MongoDB Compass. Inside this database, create a collection named 'HW6.' You can then proceed to
download the 'uscities.csv' file from the Canvas page and import it into the 'HW6' collection by clicking on
'Add Data' in the collections panel and then click on import JSON or CSV to import “uscities.csv” file.
NOTE 2:
Please utilize _MONGOSH, which is accessible within MongoDB Compass. You are allowed to employ filters
in the console solely for the purpose of verifying the query results. As part of your solution submission,
please submit query along with its corresponding output (result set).
HW-6 MongoDB
CSCI 3287: Design and Analysis of Data Systems Page 2
1. Insert a new city document into the "HW6" collection with the following details:
City: "Bangalore"
State ID: "KA"
State Name: "Karnataka"
Population: 884363
Density: 7266
2. List the names of cities with a population greater than 1 million and less than 1.05 million, and only
display city names.
3. Find the city with the highest population density, and only display city name and density value.
4. List the names of cities in California (state_id = "CA") with a population greater than 2,000,000 and
only display city names.
5. Count the number of cities with a population density above 3000, and only display count value.
6. Calculate the average population for New York (state_id = “NY”), and only display state_id and avg
population.
7. List any 3 cities name with a timezone of “America/Los_Angeles"
8. Count the number of cities that are not incorporated (false), and only display count value.
9. Count the number of cities in Florida (state_id = "FL") with population lessthan 1000 and only display
count value.
10. Find the lowest population city in Colorado (state_id="CO"), and display county name, city name with
density value.
The End.