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

MongoDB Assignments (1)

The document outlines assignments for creating and managing two databases: 'Movie' and 'Company'. Each database includes collections with specific fields and queries for inserting, updating, displaying, and deleting documents. The assignments also require the use of MongoDB's Aggregate framework for data manipulation and retrieval.

Uploaded by

yash borkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

MongoDB Assignments (1)

The document outlines assignments for creating and managing two databases: 'Movie' and 'Company'. Each database includes collections with specific fields and queries for inserting, updating, displaying, and deleting documents. The assignments also require the use of MongoDB's Aggregate framework for data manipulation and retrieval.

Uploaded by

yash borkar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment 1

1. Create a database with the name ‘Movie’.


2. A ‘Film’ is a collection of documents with the following fields:
a. Film Id
b. Title of the film
c. Year of release
d. Genre / Category (like adventure, action, sci-fi, romantic etc.)
A film can belong to more than one genre.
e. Actors (First name and Last name)
A film can have more than one actor.
f. Director (First name and Last name)
A film can have more than one director.
g. Release details (It consists of places of release, dates of release and
rating of the film.)
3. An ‘Actor’ is a collection of documents with the following fields:
a. Actor Id
b. First name
c. Last Name
d. Address (Street, City, State, Country, Pin-code)
e. Contact Details (Email Id and Phone No)
f. Age of an actor.

Queries:

1. Insert at least 10 documents in the collection Film –

a. Insert at least one document with film belonging to two genres.


b. Insert at least one document with film that is released at more than
one place and on two different dates.
c. Insert at least three documents with the films released in the same
year.
d. Insert at least two documents with the films directed by one
director.
e. Insert at least two documents with films those are acted by a pair
‘Madhuri Dixit’ and ‘Shahrukh Khan’.

2. Insert at least 10 documents in the collection Actor.

Make sure, you are inserting the names of actors who have acted in
films, given in the ‘Film’ collection.

3. Display all the documents inserted in both the collections.


4. Add a value to the rating of the film whose title starts with ‘T’.
5. Add an actor named "_____________" in the ‘Actor’ collection. Also
add the details of the film in ‘Film’ collection in which this actor has
acted in.
6. Delete the film "______________".
7. Delete an actor named "_________".
8. Delete all actors from an ‘Actor’ collection who have age greater than
“_____”
9. Update the actor’s address where Actor Id is “ ______”.
10. Update the genre of the film directed by “___________”.

-----X-----
Assignment 2:

1. Create a database with name ‘Company’.

2. An ‘Employee’ is a collection of documents with the following fields:

a. Employee ID
b. First Name
c. Last Name
d. Email
e. Phone No.
f. Address (House No, Street, City, State, Country, Pin-code)
g. Salary
h. Designation
i. Experience
j. Date of Joining
k. Birthdate

3. A ‘Transaction’ is a collection of documents with the following fields:

a. Transaction Id,
b. Transaction Date
c. Name (First Name of employee who processed the transaction)
d. Transaction Details (Item Id, Item Name, Quantity, Price)
e. Payment (Type of Payment (Debit/Credit/Cash), Total amount paid,
Payment Successful)
f. Remark (Remark field can be empty.)

Queries:

1. Insert at least 5 documents in ‘Employee’ collection.


2. Insert multiple documents (at least 10) into the ‘Transaction’ collection
by passing an array of documents to the db.collection.insert () method.
3. Display all the documents of both the collections in a formatted manner.
4. Update salary of all employees by giving an increment of Rs. 4000.
5. Update the remark for transaction id 201.
6. Update designation of an employee named “____” from supervisor to
manager.
7. Update designation of an employee having Employee Id as _____.
8. Change the address of an employee having Employee Id as _____.
9. Delete transaction made by “_____” employee on the given date.
10. Delete all the employees whose first name starts with ‘K’.

----X-----
Assignment 3:

This assignment is based on ‘Movie’ database having collections ‘Film’ and


‘Actor’.

Prerequisite: Read MongoDB Aggregate framework before executing the


following assignments.

Note: It is expected that student should fill in the data relevant to the queries
given in the assignment. The result set should not be empty.

1. Find the titles of all the films starting with the letter ‘R’ released during
the year 2009 and 2011.
2. Find the list of films acted by an actor "___________".
3. Find all the films released in 90s.
4. Find all films belonging to “Adventure” and “Thriller” genre.
5. Find all the films having ‘A’ rating.
6. Arrange the film names in ascending order and release year should be in
descending order.
7. Sort the actors in ascending order according to their age.
8. Find movies that are comedies or dramas and are released after 2013.
9. Show the latest 2 films acted by an actor “_________”.
10. List the titles of films acted by actors “________” and “___________”.
11. Retrieve films with an actor living in Spain.
12. Retrieve films with actor details.

Note: Similarly, additional queries can be executed based on these


collections for practice.

-----X-----
Assignment 4:

This assignment is based on ‘Company’ database having collections


‘Employee’ and ‘Transaction’.

Prerequisite: Read MongoDB Aggregate framework before executing the


following assignments.

Note: It is expected that student should fill in the data relevant to the queries
given in the assignment. The result set should not be empty.

1. Find employees having designation as either ‘manager’ or ‘floor


supervisor’.
2. Find an employee whose name ends with "_________" and print the
output in json format.
3. Display the name of an employee whose salary is greater than _______
using a MongoDB cursor.
4. Sort the employees in the descending order of their designation.
5. Count the total number of employees in a collection.
6. Calculate the sum of total amount paid for all the transaction documents.
7. Calculate the sum of total amount paid for each payment type.
8. Find the transaction id of the latest transaction.
9. Find designation of employees who have made transaction of amount
greater than Rs. 500.
10. Find the total quantity of a particular item sold using Map Reduce.

-----X-----

Prepared by:

Mrs. Chitra Alavani, Kaveri College of Arts, Science and Commerce.

Mrs. Rasika Rahalkar, MES’ Abasaheb Garware College.

You might also like