Nosql Exercises
Nosql Exercises
DAY - 9 ACTIVITIES
TOPIC : MONGODB
Questions
4. Write a MongoDB query to display the fields zip code, but exclude the field
_id for all the documents in the collection restaurant.
5. Write a MongoDB query to display all the restaurants which are in the
borough Brooklyn.
6. Write a MongoDB query to display the first 5 restaurants which are in the
borough Brooklyn.
Database Training Sample Activities
8. Write a MongoDB query to find the restaurants that achieved a score of more
than 70.
10. Write a MongoDB query to find the restaurants that do not prepare any
cuisine of ‘American’ and their grade score of more than 70.
11. Write a MongoDB query to find the restaurants which do not prepare any
cuisine of ‘American’ and achieved a grade point ‘A’ not belonging to the
borough Brooklyn. The document must be displayed according to
the cuisine in descending order.
12. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which contain ‘Wil’ as the first three letters of
their name.
13. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which contain ‘Food’ as the last three
letters of their name.
Database Training Sample Activities
14. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which contain ‘Seafood’ as three letters
somewhere in their name.
15. Write a MongoDB query to find the restaurants which belong to the
borough Bronx and prepared either American or Chinese dishes.
16. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which belong to the borough of Staten Island
or Queens, or Bronx Brooklyn.
17. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which do not belong to the borough Staten
Island or Queens, or Bronxor Brooklyn.
18. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which achieved a score that is not more than
10.
19. Write a MongoDB query to find the restaurant Id, name, borough, and
cuisine for those restaurants which prepared dishes except ‘American’ and
‘Chinese’ or the restaurant’s name begins with the letter ‘Sea’.
24. Write a MongoDB query to find the restaurant Id, name, and grades for
those restaurants where the 2nd element of the grades array contains a grade of
“A” and score 9 on an ISODate “2013–09–11T00:00:00Z”.
25. Write a MongoDB query to find the restaurant Id, name, and grades for
those restaurants which achieved a grade of “A” and scored 11 on an ISODate
“2013–09–11T00:00:00Z” among many of the survey dates.
26. Write a MongoDB query that will select all documents in the restaurants'
collection where the coord field value is double.
27. Write a MongoDB query that will select the restaurant Id, name, and grades
for those restaurants which returns 0 as a remainder after dividing the score by
7.
Database Training Sample Activities
28. Write a query to find the restaurants with more than three grade surveys
(‘grades’ Array contains more than three elements) and display only the name
and the number of grades.