0% found this document useful (0 votes)
65 views

Lab Sheet 4 - Mongodb Basics-1

The document provides instructions for performing operations on MongoDB databases and collections including creating databases and collections, adding documents, and writing queries. It includes examples of creating databases and collections for vehicles and animals, adding documents with various fields, and queries to retrieve specific fields or filter on certain criteria.

Uploaded by

sai22.ssb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Lab Sheet 4 - Mongodb Basics-1

The document provides instructions for performing operations on MongoDB databases and collections including creating databases and collections, adding documents, and writing queries. It includes examples of creating databases and collections for vehicles and animals, adding documents with various fields, and queries to retrieve specific fields or filter on certain criteria.

Uploaded by

sai22.ssb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

VIT-AP UNIVERSITY, ANDHRA PRADESH

Lab Sheet 4: MongoDB Basic commands

1. Use MongoDB to implement the following DB operations


1. Create a database called ‘vehicles’ and write a MongoDB query to select
database as “vehicles”.
2. Write a MongoDB query to display all the databases.
3. Create a collection called ‘two_wheelers’.(use capping) and Create a
collection called ‘four_wheelers’.
4. Add 5 two-wheeler details to the collection named ‘two_wheelers’. Each
document consists of following fields as bike_name, model (gear or gearless),
category (100cc, 125cc, 150cc, 200cc), colors_available (red, black, blue,
sport red etc) as array, manufacturer, performance (out of 10), timestamp
(date and year release) and price.
5. Add 5 four-wheeler details to the collection named ‘four_wheelers’. Each
document consists of following fields as vehicle_name, model (commercial or
own), category (car, lorry, bus, mini truck, heavy truck, containers), variants
(vxi, zxi, petrol, diesel etc) as array, manufacturer, performance (out of 10),
timestamp (date and year release) and price.
6. Write a MongoDB query to display all documents available in two_wheelers
and four_wheelers.
7. Write a MongoDB query to display only vehicle name and price in all the
collection of the database
8. Write a MongoDB query to display two_wheelers from a particular company
9. Write a MongoDB query to display four_wheelers available in diesel variants
10. Write a MongoDB query to display vehicles name, category and manufacturer
details whose rating is more than 5.

2. Use MongoDB to implement the following DB operations for a Zoo


1. Create a database called ‘animal’ and write a MongoDB query to select
database as ‘animal’.
2. Write a MongoDB query to display all the databases.
3. Create a collection called ‘wild_animals’.(use capping) and Create a collection
called ‘domestic_animals’.
4. Add 5 wild_animal details to the collection named ‘wild_animals’. Each
document consists of following fields as animal_name, nature (harm or
harmless), favorite_foods (meat, rabbits, deer etc) as array,
care_taker_name, life span (in years), timestamp (when the animal registered
at the Zoo) and expenses.
VIT-AP UNIVERSITY, ANDHRA PRADESH

Lab Sheet 4: MongoDB Basic commands

5. Add 5 domestic-animal details to the collection named ‘domestic_animals’.


Each document consists of following fields as animal_name, gender (male or
female), favorite_foods (meat, rabbits, deer etc) as array, animal_petname,
life span (in years), timestamp (when the animal registered at the Zoo) and
expenses.
6. Write a MongoDB query to display all documents available in wild_animals
and domastic_animals.
7. Write a MongoDB query to display only animal name and expenses in all the
collection of the database
8. Write a MongoDB query to display domestic_animals whose life is a particular
year
9. Write a MongoDB query to display wild_animals available under a particular
care_taker
10. Write a MongoDB query to display animal name, favorite_foods and expenses
details whose lifespan is more than 5 years.

You might also like