0% found this document useful (0 votes)
3 views4 pages

Assignment - 2

This document is an assignment for the B. Tech. 6th semester course on NoSQL Databases at M. M. Engineering College, detailing various questions and tasks related to MongoDB. It includes sections on definitions, comparisons, data modeling, CRUD operations, and practical queries for creating and manipulating databases. The assignment emphasizes understanding of MongoDB concepts and practical application through schema design and query writing.

Uploaded by

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

Assignment - 2

This document is an assignment for the B. Tech. 6th semester course on NoSQL Databases at M. M. Engineering College, detailing various questions and tasks related to MongoDB. It includes sections on definitions, comparisons, data modeling, CRUD operations, and practical queries for creating and manipulating databases. The assignment emphasizes understanding of MongoDB concepts and practical application through schema design and query writing.

Uploaded by

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

M.M.E.C M. M.

Engineering College, Mullana Assignment-II


Year: 2023-24 Semester: B. Tech. 6th
Course Code: BCSE-602 Course Name: NOSQL Databases
Date of Issue: 17.01.24 Date of Submission: Date of Evaluation:
Max. Marks: 60

Question No. Questions Marks


Section-A
1. What type of NoSQL database MongoDB is? 1
2. Define Namespace in MongoDB. 1
3. What is a Collection in MongoDB? 1
4. What is a Document in MongoDB? 1
5. What is the Mongo Shell? 1
6. Why do we use the pretty () method? 1
7. What does ObjectId contain? 1
8. How do we use a primary key in MongoDB? 1
9. Explain how to start the MongoDB Instance or Server? 1
10. Define BSON. 1
11. How does MongoDB store the data? 1
12 What are Embedded documents? 1
Section-B
13. Why MongoDB is the best NoSQL database? 2
14. What is the use of MongoDB? 2
15. Differences between MongoDB and RDBMS 2
16. What are data modeling and types of data models in MongoDB? 2

Section-C
17. What are the data types in MongoDB? 4
18. What are the CRUD operations of MongoDB? Explain with suitable example. 4
19. Suppose a client needs a database design for his blog/website. Website has the following requirements: 4
 Every post has the unique title, description and url.
 Every post can have one or more tags.
 Every post has the name of its publisher and total number of likes.
 Every post has comments given by users along with their name, message, data-time and likes.
 On each post, there can be zero or more comments.
Create a data model schema design for the website in MongoDB.
20. Create a MovieMaker Database with a collection called “Movies “containing documents with some or all of 4
the following fields: titles, directors, years, actors. Perform the following operations on the database (either in

the console or using any programming language):


a. Retrieve all documents
b. Retrieve all documents with Director set to "Quentin Tarantino"
c. Retrieve all documents where actors include "Brad Pitt".
d. Retrieve all movies released before the year 2000 or after 2010.
e. Add a synopsis to "The Hobbit: An Unexpected Journey”: "A reluctant hobbit, Bilbo Baggins, sets
out to the Lonely Mountain with a spirited group of dwarves to reclaim their mountain home - and
the gold within it - from the dragon Smaug."
f. Add a synopsis to "The Hobbit: The Desolation of Smaug”: "The dwarves, along with Bilbo Baggins
and Gandalf the Grey, continue their quest to reclaim Erebor, their homeland, from Smaug. Bilbo
Baggins is in possession of a mysterious and magical ring."
g. Add an actor named "Samuel L. Jackson" to the movie "Pulp Fiction"
h. Find all movies that have a synopsis that contains the word "Bilbo"
i. Find all movies that have a synopsis that contains the word "Gandalf"
j. Find all movies that have a synopsis that contains the word "Bilbo" and not the word "Gandalf"
k. Find all movies that have a synopsis that contains the word "dwarves" or "hobbit"
l. Find all movies that have a synopsis that contains the word "gold" and "dragon".
m. Delete the movie "Pee Wee Herman's Big Adventure”
Section-D
21. Structure of 'restaurants' collection: 6

{
"address": {
"building": "1007",
"coord": [ -73.856077, 40.848447 ],
"street": "Morris Park Ave",
"zipcode": "10462"
},
"borough": "Bronx",
"cuisine": "Bakery",
"grades": [
{ "date": { "$date": 1393804800000 }, "grade": "A", "score": 2 },
{ "date": { "$date": 1378857600000 }, "grade": "A", "score": 6 },
{ "date": { "$date": 1358985600000 }, "grade": "A", "score": 10 },
{ "date": { "$date": 1322006400000 }, "grade": "A", "score": 9 },
{ "date": { "$date": 1299715200000 }, "grade": "B", "score": 14 }
],
"name": "Morris Park Bake Shop",
"restaurant_id": "30075445"
}
a. Write a MongoDB query to display all the documents in the collection restaurants.
b. Write a MongoDB query to display the fields restaurant_id, name, borough and cuisine for all the
documents in the collection restaurant.
c. Write a MongoDB query to display the fields restaurant_id, name, borough and cuisine, but exclude
the field _id for all the documents in the collection restaurant.
d. Write a MongoDB query to display the fields restaurant_id, name, borough and zip code, but ex-
clude the field _id for all the documents in the collection restaurant.
e. Write a MongoDB query to display all the restaurant which is in the borough Bronx.
f. Write a MongoDB query to display the first 5 restaurant which is in the borough Bronx.
g. Write a MongoDB query to display the next 5 restaurants after skipping first 5 which are in the bor-
ough Bronx.
h. Write a MongoDB query to find the restaurants who achieved a score more than 90.
i. Write a MongoDB query to find the restaurants that achieved a score, more than 80 but less than
100.
j. Write a MongoDB query to find the restaurants which locate in latitude value less than -5.754168.
k. 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.
l. Write a MongoDB query to find the restaurants which do not prepare any cuisine of 'American' and
achieved a score more than 70 and located in the longitude less than -65.754168. Note: Do this query
without using $and operator.
22. Create a database with the name ‘Movie’. A ‘Film’ is a collection of documents with the following fields: (a)
6
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.). 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 "Ram" 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 “XYZ".
7. Delete an actor named "Jitendra Kumar ".
8. Delete all actors from an ‘Actor’ collection who have age greater than “55”.
9. Update the actor’s address where Actor Id is 101.
10. Update the genre of the film directed by “David Dhawan”.
6
23.

a. Find all the books with a number of pages greater than 250.
b. Find all the books authored by Mario Rossi.
c. Find all the books with a price less than 20 € for Italy (IT).
d. Increase the review score of 0.2 points for all the books with the tag “database”.
e. Insert the tag “NoSQL” for all the books with tag “mongodb”.
f. Insert the publisher for all the documents authored by Mario Rossi with the default value {‘name’:
‘Polito’, city:’Turin’}.
Design a MongoDB database to manage the parcel delivery according to the following requirements: 6
24.  Customers of the parcel delivery service are citizens identified by their social security number. They
can be senders or recipients of delivered parcels. They are characterized by their name, surname,
email address, a telephone number, and by different addresses, one for each type (e.g., one billing
address, one home address, one work address, etc.). Each address consists of street name, street
number, postal code, city, province, and country.
 Parcels are characterized by a unique barcode and their physical dimensions (specifically: width,
height, depth, and weight). All widths, heights, and depths are always expressed in meters. All
weights are always expressed in kilograms.
 The recipient and the sender information required to deliver each parcel must be always available
when accessing the data of a parcel. Recipient and sender information required to deliver a parcel
consists of full name, street name, street number, postal code, city, province, and country.
 The parcel warehouse is divided into different areas. Each area is identified by a unique code, e.g.,
'area_51' and consists of different lines. Each line is identified by unique code, e.g., 'line_12', and
hosts several racks. Each rack is identified by unique code, e.g., 'rack_33', and is made up of shelves.
Each parcel is placed on a specific shelf of the warehouse, identified by a unique code, e.g.,
'shelf_99'. The database is required to track the location of each parcel within the warehouse.
 Given a parcel, the database must be designed to efficiently provide its full location, from the shelf,
up to the area, through rack and line.
 Given a customer, the database must be designed to efficiently provide all her/his parcels as a
sender, and all his/her parcels as a recipient.
Indicate for each collection in the database the document structure and the strategies used for modeling.

You might also like