Starting from:

$34.99

DSCI551 Lab3 -MongoDB Solution


Consider three json files: country.json, city.json, countrylanguage.json. The files are given to you in a zip file: country.zip. To extract the content, execute: unzip country.zip.
Import the files into MongoDB on EC2 as follows:
mongoimport --file country.json --db world --collection country mongoimport --file city.json --db world --collection city mongoimport --file countrylanguage.json --db world --collection countrylanguage
Note the above commands will create three collections: country, city, and countrylanguage, in a database called world.
Write a MongoDB script (using functions such as find, aggregate, update, etc.) for each of the following questions.
1. Find names of countries whose GNP is between 10,000 and 15,000, inclusive. Output names only (no _id either).
2. Find out how many countries have zero in their Capital values. (Capital is for Capital city id).
3. Find out how many unique continents there are in the country collection.
4. Find names and GNPs of top-5 countries with the highest GNP. Output names and GNPs only.
5. Find languages that are official languages and spoken by at least 95% of the population in the country where the language is official. Return the same language once.
6. Find names of cities whose name contains Los (case insensitive) and has at least 200,000 people.
Return names of cities only.
7. Find out, for each continent, the average GNP of countries in the continent.
8. Find top-10 most popular official language, ranked by the number of countries where the language is official (i.e., the count). Return language and count.
9. Find names of countries and their capital cities, for all countries in North America and having a GNP of at least 100,000. Output country and capital city names only.
10. Find names of countries in North America continent where English is an official language.
Submission Requirements:
Please read the following 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:
Q1 Script: db.country.find(...........................1)
OUTPUT:
{ Name: 'Belgium' },
{ Name: 'Germany' },
{ Name: 'Greece' },
.
.
.
.
Q2 Script: db.country.find(...........................1)
OUTPUT:
{ Name: 'Belgium' },
{ Name: 'Germany' },
{ Name: 'Greece' },
.
.
.
.
And so on

More products