MongoDb Lab Progam Syllabus
MongoDb Lab Progam Syllabus
MongoDB Lab(22CDL471)
a) Add documents to the collection using insert and insertMany with columns – rollno, name, city ,
multiple address .
2 Create an Employee Database in MongoDB by creating a collection that includes the below mentioned fields to store
employee information
Emp_id, name, age, department, salary, skills, projects, address
[ Note: Multi-valued attributes: skills, projects (stored as arrays).
Composite attributes: address contains city, state, country (stored as embedded documents)]
1. Insert at least five employee documents into the collection, ensuring each document contains appropriate field values
2. Write a MongoDB query to retrieve all employee records from the employee collection.
3. Write a query to find all employees working in the "HR" department.
4. Retrieve employees who earn more than $50,000.
5. Write a MongoDB query to retrieve all employees whose salary is greater than 50,000 and less than 80,000 from the
employee collection.
6. Write a MongoDB query to retrieve all employees who reside in USA from the employee collection.
7. Write a query to find employees who work in the "HR" department and have earn more than 100000
9. Write a query to update the age of the employee with Emp_id 101 to 30
10. Write a query to remove the projects field from the employee document with Emp_id 102
3 Create an Employee Database in MongoDB by creating a collection that includes the below mentioned fields to
store employee information
Emp_id, name, age, department, salary, skills, projects, address
[ Note: Multi-valued attributes: skills, projects (stored as arrays).
1. Write a query to rename the field department to dept for the employee with Emp_id 103
2. Write a query to increment the salary of the employee with Emp_id 104 by 5000
3. Write a query to increase the salary of the employee with Emp_id 105 by 10%
4. Write a query to add the skill 'Leadership' to the employee with Emp_id 101 only if it doesn’t already exist
5. Write a query to add a new project called 'New Initiative' to the employee with Emp_id 102.
6. Write a query to remove the first element from the skills array of the employee with Emp_id 103
7. Write a query to remove the skill 'Recruitment' from the skills array of the employee with Emp_id 104.
8. Write a query to update the lastModified field with the current date for the employee with Emp_id 105
9. Write a query to update the salary of the employee with Emp_id 101 to 130000, only if their current salary is
less than that
10. Write a query to update the age of the employee with Emp_id 102 to 32, only if their current age is greater
DAYANANDA SAGAR COLLEGE OF ENGINEERING
(An Autonomous Institute affiliated to Visvesvaraya Technological University (VTU), Belagavi,
Approved by AICTE and UGC, Accredited by NAAC with 'A' grade & ISO 9001-2015 Certified Institution)
Shavige Malleshwara Hills, Kumaraswamy Layout, Bengaluru - 560 111. India
than 32?
a) Write a MongoDB query to find the restaurants who achieved a score more than 90
b) Write a MongoDB query to find the restaurants that do not prepare any cuisine of 'American' and their
grade score more than 70 and latitude less than -65.754168.
c) Write a MongoDB query to find the restaurant Id, name, borough and cuisine for those restaurants
which contain 'Wil' as first three letters for its name.
d) Find the restaurant Id, name, borough and cuisine for those restaurants which contain ces as last three
letters for its name
e) Write a query to update the name of the restaurant with ID your name.
a) 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 "2014-08-11T00:00:00Z" among many of survey
dates.
b) Write a MongoDB query to find the restaurant Id, name, address and geographical location for tho it se
restaurants where 2nd element of coord array contains a value which is more than 42 and upto 52.
c) Write a MongoDB query to find the average score for each restaurant.
d) Write a MongoDB query to find the count of restaurants for each cuisine and borough.
e) Create a query to update all grade scores of the restaurant with given ID to increase them by 5 points.
a)Write a MongoDB query to find the name and address of the restaurants that received a grade of 'B' or 'C'
on a specific date.
b) Write a MongoDB query to find the name and address of the restaurants that have at least one 'A'
grade and no 'B' grades.
c)Write a MongoDB query to find the name and address of the restaurants that have the word 'coffee' in
their name.
d) Write a MongoDB query to find the name, address, and cuisine of the restaurants that have a cuisine
that contains the word 'Pizza'.
e)Create a query to delete all restaurants where the lowest grade score is below 50.
a) Write an aggregation query to find the highest score achieved by any restaurant in each cuisine
b) Write a MongoDB query to find the restaurant with the most recent grade date.
c) Write a MongoDB query to find the restaurant that has the highest average score for the cuisine
"Turkish".
d) Construct a query to delete all restaurants located in a city with a population of less than 100,000
DAYANANDA SAGAR COLLEGE OF ENGINEERING
(An Autonomous Institute affiliated to Visvesvaraya Technological University (VTU), Belagavi,
Approved by AICTE and UGC, Accredited by NAAC with 'A' grade & ISO 9001-2015 Certified Institution)
Shavige Malleshwara Hills, Kumaraswamy Layout, Bengaluru - 560 111. India
a) Find all movies with title, languages, released, directors, viewer, writers, countries from the
'movies' collection in MongoDB that have a viewer rating of at least 3 and less than 4 on Tomatoes.
d) Find from the 'movies' collection in MongoDB with the most common genre among the movies
e) Drop the collection and recreate it with the same data using command line
Mini Project:
Students are expected to do a mini project and submit for evaluation for SEE.
Expectations:
1. Create a Json file with minimum of 100 documents (other than the movies and restaurants
data used in the experiments ) and load it . Json Data should contain different formats of
data.
2. Perform 25 CRUD operations on the same data set. MongoDB queries should include at least
a) 5 Aggregation operations which groups data, perform max, min, sum and average on the
columns to display top or 10 documents post operations
b) 15 queries to select documents based on different filter including or, and, equal and not
equal operations. Selecting required fields
c) 3 update operations of medium complexity
d) 2 delete operations