wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ISP610 MONGODB

Total questions: 20

Worksheet time: 13mins

Name
Class
Date
1.

Which of the following commands is used to show all databases in MongoDB?

a)

db.showDatabases()

b)

show dbs

c)

show databases()

d)

db.listDatabases()

2.

Which MongoDB method is used to insert a single document into a collection?

a)

db.collection.addOne()

b)

db.collection.insert()

c)

db.collection.insertOne()

d)

db.collection.save()

3.

Identify the syntax error:

db.users.insertOne({name: John, age: 30})

a)

Missing semicolon

b)

John must be in quotes

c)

The entire document must be in quotes

d)

No syntax error

4.

To find all documents where status is "active", the correct query is:

a)

db.users.find({status = "active"})

b)

db.users.find(status: "active")

c)

db.users.find({status: "active"})

d)

db.users.select({status: "active"})

5.

Which command deletes all documents from a collection named orders?

a)

db.orders.drop()

b)

db.orders.remove()

c)

db.orders.truncate()

d)

db.orders.deleteMany({})

6.

Which aggregation stage is used to group documents by a specific field?

a)

$match

b)

$group

c)

$project

d)

$lookup

7.

What will this command do?

db.students.updateMany({}, {$inc: {score: 5}})

a)

Replace all documents with {score: 5}

b)

Increase score by 5 for all students

c)

Add a new field score with value 5 for one document

d)

Error — $inc cannot be used in updateMany()

8.

The _id field in MongoDB can be manually set during insertion.

a)

TRUE

b)

FALSE

9.

Which of the following is the correct syntax to sort query results by age in descending order?

a)

db.users.sort({age: desc})

b)

db.users.find().orderBy(age, "desc")

c)

db.users.find().sort({age: -1})

d)

db.users.find({}).sort(age: -1)

10.

Identify the error:

db.employees.find({salary: {$gte: 5000 $lte: 10000}})

a)

No error

b)

Use of wrong operator syntax

c)

$gte must come after $lte

d)

Missing comma between $gte and $lte

11.

In an aggregation pipeline, which stage allows you to reshape or select specific fields from documents?

a)

$match

b)

$project

c)

$group

d)

$lookup

12.

What does the following aggregation do?

db.sales.aggregate([ { $group: { _id: "$region", totalSales: { $sum: "$amount" } } } ])

a)

Merges all documents into one total

b)

Lists each sale individually

c)

Filters only regions with totalSales > 0

d)

Groups all documents by region and sums up their sales amounts

13.

In MongoDB, the field that uniquely identifies each document is called (a)   .

14.

To join data from another collection inside an aggregation pipeline, we use the stage (a)   .

15.

To remove a field from a document using an update operation, you can use
{ $ (a)   : { fieldName: "" } }.

16.

In MongoDB, when related data is stored within the same document, it is called (a)   .

17.

When related data is stored in a separate collection and linked using an id or other field, it is called (a)   .

18.

Embedding data in MongoDB usually provides faster reads because all related data is in one document.

a)

TRUE

b)

FALSE

19.

Referencing creates data duplication because the same information is stored in multiple documents.

a)

TRUE

b)

FALSE

20.

Which of the following is an example of embedding in MongoDB?

a)

Storing author information directly inside each book document

b)

Creating an index on author_id

c)

Storing all book details inside a books collection and linking with author_id

d)

Joining books and authors collections using $lookup