0% found this document useful (0 votes)
18 views13 pages

DBMS MongoDB CRUD

Uploaded by

deshmukhe0611
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)
18 views13 pages

DBMS MongoDB CRUD

Uploaded by

deshmukhe0611
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/ 13

Q1.

Create a collection Social_Media having fields as User_Id, User_Name, No_of_Posts,


No_of_Friends, Friends_List, Interests. (Hint: Friends_List and Interests can be of array type).Insert
20 documents in the collection Social_Media. Write queries for following:

1. List all the users from collection Social_Media in formatted manner.


2. Find all users having number of posts greater than 100.
3. List the user names and their respetive Friends_List

4. Display the user ids and Friends list of users who have more than 5 friends.
5. Display all users with no of posts in descending order.
Q2. Create a collection Employee with fields as Emp_id, Emp_Name, Department, Salary, Manager.

Insert 20 documents in the collection Employee. Write the queries for following.

1. Find the names of Employees having top 5 highest salaries.

2. List the records of employees having Department as “R&D” or Manager as “Smith”.


3. Update the salary of Emp_id 100 as 200000.

4. Delete the record of employee having name as “Josh”


5. List the Department of employees having salary less than 50000.
Q3. Create collection Student with fields as Roll_No, Name, Class, Marks, Address,
Enrolled_Courses. (Hint: One student can enroll in multiple courses. Use Array to store the names
of courses enrolled) Insert 10 documents in the collection Student. Write the queries for following.

1. List the names of students who have enrolled in the course “DBMS”, “TOC”.
2. List the Roll numbers and class of students who have marks more than 50 or class as TE.

3. Update the entire record of roll_no A10.


4. Display the names of students having 3rd and 4th highest marks.

5. Delete the records of students having marks less than 20.

6. Delete only first record from the collection.


Q4. Create a collection Products with fields as item_id, item_Name, Price, Tags, Status,
Quantity.Insert 10 documents in the collection Products. Write the queries for following.

1. List all the products with quantity equal to 50.


2. Find all the procucts having tags as "apparel" or "clothing".

3. Update the record of Item_id 100 with quanity as 100 and tags as tags: ["coats", "outerwear",
"clothing" ].
4. Delete only first record from the collection.

5.Delete all records from collection with Status as “Pending”.

You might also like