Exercise related to working with MongoDB
To check the result please download the pdf file
The exercise :
A. After downloading data, save them to the mongodb manually. (capture one sample of adding your data to your answer(PDF)) Note: Capture your insert code and it’s result. If you have many things, capture just one sample of insertion.
B. Make the following queries. Capture the results and paste them to your
answer(PDF).
Note: Capture the queries and its results.
-At the end of each day, we want to grant a discount code or a gift to those
whose birthday is today and send them a “Happy Birthday” email. Find the
full name and email address of these guys.(By running the query we can
have the info of those users which their birthday is today)
-Which city has the most number of users and which one has the least
number of users?
-Compare the average of users’ age in Tehran with the average of users’
age in other cities.
-For an advertisement, we want to categorize users based on their age.
Write a query to categorize them into three groups
1)youth 2)middle-aged 3)old:
Youth for ages < 16
Middle-aged for 16 < ages <40
Old for ages >40
-Find the number of users based on their province(=state). For example Isfahan, 30
Tehran, 50
C. By using pymongo, save the information of these users to a new collection and make sure that the info of all users is saved to your collection using “count”.