WorksheetsMongo DB NoSQL
Total questions: 44
Worksheet time: 56mins
What is MongoDB?
A) Relational Database Management System (RDBMS)
B) Document-Oriented NoSQL Database
C) Key-Value Store
D) Graph Database
Which language is primarily used for querying MongoDB?
A) SQL
B) C#
C) JavaScript
D) Python
What does BSON stand for in MongoDB?
A) Binary Object Notation
B) Basic Object Serialization Notation
C) Binary JSON
D) Big Object Storage Notation
What is a MongoDB database?
A) A group of related collections.
B) A group of related documents.
C) A group of related tables.
D) None of the mentioned above
A record in MongoDB is a:
A) Document.
B) Table.
C) Application.
D) None of the mentioned above.
What type of data model does MongoDB use?
A) Relational.
B) Document-oriented.
C) Key-value.
D) Graph.
Which of the following statements about MongoDB collections is true?
A) Collections are equivalent to tables in relational databases.
B) Collections store documents with a fixed schema.
C) Collections can be nested within other collections.
D) None of the mentioned above.
What does CRUD stand for in the context of MongoDB operations?
Create, Read, Update, Delete
Copy, Remove, Update, Drop
Collect, Retrieve, Unify, Deploy
Connect, Render, Utilize, Deploy
How does MongoDB handle schema flexibility compared to traditional relational databases?
MongoDB enforces a rigid schema
MongoDB has a dynamic schema
MongoDB does not support schemas
MongoDB requires explicit schema definitions for each collection
What is the purpose of the "_id" field in MongoDB documents?
It defines the data type of the document
It represents the document's primary key
It specifies the database name
It determines the document's index
Which of the following is a valid MongoDB JSON document:
{}
{ "user_id"=1, "user_name"="Joe Sanders", "occupation"=["engineer","writer"] }
{ "user_id":1; "user_name":"Joe Sanders"; "occupation":["engineer","writer"] }
{ "user_id":1, "user_name":"Joe Sanders", "occupation":[ "occupation1":"engineer", "occupation2":"writer" ] }
Consider that you have the following two documents in the products collection:
{ "_id" : 1, "prices" : [ 60, 100, 200 ] }
{ "_id" : 2, "prices" : [ 20, 90, 150 ] }
What will the following query result into:
db.products.update( { _id: 1, prices: 100 }, { $set: { "prices.$" : 111 } } )
Updates 60 to 100
Updates 100 to 111
Updates 60,100 and 200 to 111
Removes the three elements of the prices array and replaces it only a single element 111
Which of the following aggregation query will sort the posts collection with author key ascending:
db.posts.aggregate([ {$sort:{ author:1 } } ])
db.posts.aggregate([ {$sort:{ author:-1 } } ])
db.posts.aggregate([ {author: {$sort: 1} } ])
You need to first use $group or $project or $match command before $sort in the pipeline
In a collection that contains 100 post documents, what does the following command do?
db.posts.find().skip(5).limit(5)
Skip and limit nullify each other. Hence returning the first five documents.
Skips the first five documents and returns the sixth document five times
Skips the first five documents and returns the next five
Limits the first five documents and then return them in reverse order
Consider a collection posts which has fields: id, posttext, post_author, post_timestamp, post_tags etc. Which of the following query retrieves ONLY the key named post_text from the first document retrieved?
db.posts.find({},{_id:0, post_text:1})
db.posts.findOne({post_text:1})
db.posts.finOne({},{post_text:1})
db.posts.findOne({},{_id:0, post_text:1})
A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
Table and Row
Table and Column
Column and Row
Database and Table
Which of the following MongoDB query is equivalent to the following SQL query:
UPDATE users SET status = "C" WHERE age > 25
db.users.update( { age: { $gt: 25 } }, { status: "C" })
db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } })
db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } }, { multi: true })
db.users.update( { age: { $gt: 25 } }, { status: "C" }, { multi: true })
Which language is MongoDB written in?
C++
Java
Python
MongoC
What is the equivalent command in MongoDB for the following SQL query?
SELECT * FROM posts WHERE author like "%john%"
db.posts.find( { author: /john/ } )
db.posts.find( { author: {$like: /john/} } )
db.posts.find( { $like: {author: /john/} } )
db.posts.find( { author: /^john^/ } )
Point out the correct statement.
MongoDB is classified as a NoSQL database
MongoDB favours XML format more than JSON
MongoDB is column oriented database store
All of the mentioned
Initial release of MongoDB was in the year?
2000
2005
2009
2011
____________ method renders the document in a JSON-like format.
displayjson
printjson
printdoc
The __________ method limits the number of documents in the result set.
limit
limitOf
limitBy
None of the Above
Which of the following line skips the first 5 documents in the bios collection and returns all remaining documents?
db.bios.find().limit( 5 )
db.bios.find().skip( 1 )
db.bios.find().skip( 5)
db.bios.find().sort( 5 )
What is the interactive shell for MongoDB called?
Mongo
dbmong
mongosh
mongodb
What is the maximum size of a MongoDB document?
2MB
16MB
12MB
No limit.Depends on RAM
mongo looks for a database server listening on port
27017
8080
23
443
__________ command display the list of databases.
display dbs
show db
show dbs
ls
MongoDB has been adopted as ________ software by a number of major websites and services.
frontend
backend
proprietary
ALL
MongoDB is a _________ database that provides high performance, high availability, and easy scalability.
graph
key value
document
all
Which of the following operation adds a new document to the users collection?
add
insert
truncate
drop
Command to check existence of collection is
(a)
method is used to query documents in collections?
(a)
After starting the mongo shell, your session will use the (a) database by default.
_id is a (a) bytes hexadecimal number which assures the uniqueness of every document.
The following key is used to denote uniqueness in the collection?
id_
_id
id-
id
What name is given to columns in MongoDB?
Collections
Fields
Documents
Database
(a) is the command to create database named "myDB" in MongoDB.
which of the following will display only students name and GPA?
db.Students.find({},{"sName":1, "GPA":1})
db.Students.find({},{"sName":1, "GPA":1, "_id":0})
db.Students.find({},{"sName":1, "GPA":0})
db.Students.find({"sName":1, "GPA":1, "_id":0})
Which of the following will display details of sName "Sumit"?
db.Students.find({sName: "Sumit"})
db.Students.find({sName: "Sumit"},{"sName":1, "GPA":1, "_id":0})
db.Students.find({sName: "Sumit"},{"sName":1, "GPA":0})
db.Students.find({sName: Sumit})
Which of the following will display the number of students having GPA greater than 3.7?
db.Students.find({})
db.Students.find({GPA:3.7})
db.Students.find({GPA:{$gt:3.7}})
db.Students.find({$gt:{GPA:3.7}})
Which of the following will display the number of students having GPA greater than 3.7?
db.Students.find({})
db.Students.find({GPA:3.7})
db.Students.find({GPA:{$gt:3.7}})
db.Students.find({$gt:{GPA:3.7}})
Which of the following is a valid data type in MongoDB?
String
Float
Date
All of the options
Which MongoDB operation is used to insert a new document into a collection?
db.collection.create()
db.collection.add()
db.collection.insertOne()
db.collection.updateOne()
