Lab 2 MongoDB DSCI 551 solved




5/5 - (1 vote)

Use the provided aqi.json file, write a MongoDB operation (find, update, aggregate, etc) to answer each
of the following questions. Note: you need to first import it to MongoDB, e.g.,
mongoimport –file aqi.json –db dsci551 –collection aqi
will import the file to dbsci551 database as collection aqi.
1. Find out how many entries (documents) there are for USA in August of 2022.
2. Find out which date for USA in 08/2022 has more than one entry in the aqi collection.
3. Remove the entry you found in the previous question with a lower aqi value from the collection.
4. Compute the average AQI for USA in 08/2022.
5. Find out how many different countries there are in the aqi collection.
6. Find out how many entries there are in 2023 for each country.
7. Find out the average AQI value for each country in 2023.
8. Find out which countries had the highest AQI in the year 2022. Report country names and dates.
9. Find out which countries had the largest number of days with Moderate status in 2023.
10. Find out the number of countries whose AQI values were between 90 and 100 (inclusive) in
December of 2022.

Submission Requirements:

Please read carefully before submitting your work:
1. You need to submit a PDF file as your submission
2. The file must contain both the mongodb script as well as the outputs for the corresponding
questions. The file should look like this:
Q-1) . . . . . . .)
{. . . . . . . },
.. and so on.