Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Mongo DB NoSQL

Total questions: 44

Worksheet time: 56mins

Name
Class
Date
1.

What is MongoDB?

a)

A) Relational Database Management System (RDBMS)

b)

B) Document-Oriented NoSQL Database

c)

C) Key-Value Store

d)

D) Graph Database

2.

Which language is primarily used for querying MongoDB?

a)

A) SQL

b)

B) C#

c)

C) JavaScript

d)

D) Python

3.

What does BSON stand for in MongoDB?

a)

A) Binary Object Notation

b)

B) Basic Object Serialization Notation

c)

C) Binary JSON

d)

D) Big Object Storage Notation

4.

What is a MongoDB database?

a)
  • A) A group of related collections.

b)
  • B) A group of related documents.

c)
  • C) A group of related tables.

d)
  • D) None of the mentioned above

5.
  1. A record in MongoDB is a:

a)
  • A) Document.

b)
  • B) Table.

c)
  • C) Application.

d)
  • D) None of the mentioned above.

6.

What type of data model does MongoDB use?

a)
  • A) Relational.

b)
  • B) Document-oriented.

c)
  • C) Key-value.

d)
  • D) Graph.

7.

Which of the following statements about MongoDB collections is true?

a)
  • A) Collections are equivalent to tables in relational databases.

b)
  • B) Collections store documents with a fixed schema.

c)
  • C) Collections can be nested within other collections.

d)
  • D) None of the mentioned above.

8.

What does CRUD stand for in the context of MongoDB operations?

a)

Create, Read, Update, Delete

b)

Copy, Remove, Update, Drop

c)

Collect, Retrieve, Unify, Deploy

d)

Connect, Render, Utilize, Deploy

9.

How does MongoDB handle schema flexibility compared to traditional relational databases?

a)

MongoDB enforces a rigid schema

b)

MongoDB has a dynamic schema

c)

MongoDB does not support schemas

d)

MongoDB requires explicit schema definitions for each collection

10.

What is the purpose of the "_id" field in MongoDB documents?

a)

It defines the data type of the document

b)

It represents the document's primary key

c)

It specifies the database name

d)

It determines the document's index

11.

Which of the following is a valid MongoDB JSON document:

a)

{}

b)

{ "user_id"=1, "user_name"="Joe Sanders", "occupation"=["engineer","writer"] }

c)

{ "user_id":1; "user_name":"Joe Sanders"; "occupation":["engineer","writer"] }

d)

{ "user_id":1, "user_name":"Joe Sanders", "occupation":[ "occupation1":"engineer", "occupation2":"writer" ] }

12.

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 } } )

a)

Updates 60 to 100

b)

Updates 100 to 111

c)

Updates 60,100 and 200 to 111

d)

Removes the three elements of the prices array and replaces it only a single element 111

13.

Which of the following aggregation query will sort the posts collection with author key ascending:

a)

db.posts.aggregate([ {$sort:{ author:1 } } ])

b)

db.posts.aggregate([ {$sort:{ author:-1 } } ])

c)

db.posts.aggregate([ {author: {$sort: 1} } ])

d)

You need to first use $group or $project or $match command before $sort in the pipeline

14.

In a collection that contains 100 post documents, what does the following command do?

db.posts.find().skip(5).limit(5)

a)

Skip and limit nullify each other. Hence returning the first five documents.

b)

Skips the first five documents and returns the sixth document five times

c)

Skips the first five documents and returns the next five

d)

Limits the first five documents and then return them in reverse order

15.

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?

a)

db.posts.find({},{_id:0, post_text:1})

b)

db.posts.findOne({post_text:1})

c)

db.posts.finOne({},{post_text:1})

d)

db.posts.findOne({},{_id:0, post_text:1})

16.

A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?

a)

Table and Row

b)

Table and Column

c)

Column and Row

d)

Database and Table

17.

Which of the following MongoDB query is equivalent to the following SQL query:

UPDATE users SET status = "C" WHERE age > 25

a)

db.users.update( { age: { $gt: 25 } }, { status: "C" })

b)

db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } })

c)

db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } }, { multi: true })

d)

db.users.update( { age: { $gt: 25 } }, { status: "C" }, { multi: true })

18.

Which language is MongoDB written in?

a)

C++

b)

Java

c)

Python

d)

MongoC

19.

What is the equivalent command in MongoDB for the following SQL query?

SELECT * FROM posts WHERE author like "%john%"

a)

db.posts.find( { author: /john/ } )

b)

db.posts.find( { author: {$like: /john/} } )

c)

db.posts.find( { $like: {author: /john/} } )

d)

db.posts.find( { author: /^john^/ } )

20.

Point out the correct statement.

a)

MongoDB is classified as a NoSQL database

b)

MongoDB favours XML format more than JSON

c)

MongoDB is column oriented database store

d)

All of the mentioned

21.

Initial release of MongoDB was in the year?

a)

2000

b)

2005

c)

2009

d)

2011

22.

____________ method renders the document in a JSON-like format.

a)

displayjson

b)

print

c)

printjson

d)

printdoc

23.

The __________ method limits the number of documents in the result set.

a)

limit

b)

limitOf

c)

limitBy

d)

None of the Above

24.

Which of the following line skips the first 5 documents in the bios collection and returns all remaining documents?

a)

db.bios.find().limit( 5 )

b)

db.bios.find().skip( 1 )

c)

db.bios.find().skip( 5)

d)

db.bios.find().sort( 5 )

25.

What is the interactive shell for MongoDB called?

a)

Mongo

b)

dbmong

c)

mongosh

d)

mongodb

26.

What is the maximum size of a MongoDB document?

a)

2MB

b)

16MB

c)

12MB

d)

No limit.Depends on RAM

27.

mongo looks for a database server listening on port

a)

27017

b)

8080

c)

23

d)

443

28.

__________ command display the list of databases.

a)

display dbs

b)

show db

c)

show dbs

d)

ls

29.

MongoDB has been adopted as ________ software by a number of major websites and services.

a)

frontend

b)

backend

c)

proprietary

d)

ALL

30.

MongoDB is a _________ database that provides high performance, high availability, and easy scalability.

a)

graph

b)

key value

c)

document

d)

all

31.

Which of the following operation adds a new document to the users collection?

a)

add

b)

insert

c)

truncate

d)

drop

32.

Command to check existence of collection is

(a)  

33.

method is used to query documents in collections?

(a)  

34.

After starting the mongo shell, your session will use the (a)   database by default.

35.

_id is a (a)   bytes hexadecimal number which assures the uniqueness of every document.

36.

The following key is used to denote uniqueness in the collection?

a)

id_

b)

_id

c)

id-

d)

id

37.

What name is given to columns in MongoDB?

a)

Collections

b)

Fields

c)

Documents

d)

Database

38.

(a)   is the command to create database named "myDB" in MongoDB.

39.

which of the following will display only students name and GPA?

a)

db.Students.find({},{"sName":1, "GPA":1})

b)

db.Students.find({},{"sName":1, "GPA":1, "_id":0})

c)

db.Students.find({},{"sName":1, "GPA":0})

d)

db.Students.find({"sName":1, "GPA":1, "_id":0})

40.

Which of the following will display details of sName "Sumit"?

a)

db.Students.find({sName: "Sumit"})

b)

db.Students.find({sName: "Sumit"},{"sName":1, "GPA":1, "_id":0})

c)

db.Students.find({sName: "Sumit"},{"sName":1, "GPA":0})

d)

db.Students.find({sName: Sumit})

41.

Which of the following will display the number of students having GPA greater than 3.7?

a)

db.Students.find({})

b)

db.Students.find({GPA:3.7})

c)

db.Students.find({GPA:{$gt:3.7}})

d)

db.Students.find({$gt:{GPA:3.7}})

42.

Which of the following will display the number of students having GPA greater than 3.7?

a)

db.Students.find({})

b)

db.Students.find({GPA:3.7})

c)

db.Students.find({GPA:{$gt:3.7}})

d)

db.Students.find({$gt:{GPA:3.7}})

43.

Which of the following is a valid data type in MongoDB?

a)

String

b)

Float

c)

Date

d)

All of the options

44.

Which MongoDB operation is used to insert a new document into a collection?

a)

db.collection.create()

b)

db.collection.add()

c)

db.collection.insertOne()

d)

db.collection.updateOne()