wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

MongoDB Concepts 1

Total questions: 10

Worksheet time: 7mins

Name
Class
Date
1.

Which document formats are typically used for documents stored in a document-based NoSQL database?

a)

XML and CSV format.

b)

XML and JSON format.

c)

CSV and JSON format.

d)

PDF and JSON format.

2.

Which of the following tasks cannot be completed with an aggregation pipeline? (Select one.)

a)

Filtering for relevant pieces of data

b)

Finding data from outside sources

c)

Grouping documents

d)

Calculating total values from a field across many documents

3.

You have a collection that contains zip codes in the United States. Here’s a sample document from this collection:

{ "_id": ObjectId('5c8eccc1caa187d17ca6eea2'),

"city": "EVERGREEN",

"zip": "36401",

"loc": { "y": 31.458009, "x": 86.925771 },

"pop": 8556, "state": "AL" }

What will the output of this aggregation pipeline be? (Select one.)

db.zips.aggregate([ { $match: { "state": "CA" } }, { $group: { "_id": "$zip" } } ])

a)

One document for each city located in California (CA)

b)

One document for each zip code located in California (CA)

c)

The total number of documents that contain a zip code in the state of California (CA)

d)

All documents that contain a zip where the state is California (CA)

4.

What does the $count stage return? (Select one.)

a)

A single document with one field that contains the value set to the number of documents at this stage in the aggregation pipeline.

b)

The number of groups in an aggregation pipeline.

c)

A set number of documents from the aggregation pipeline.

d)

A single document that contains the number of fields that have been modified in an aggregation pipeline.

5.

  1. Which query operator in MongoDB is used to compare if a value is greater than another?

a)

  • $lt

b)

$gte

c)

$gt

d)

$eq

6.

  1. Which of the following is not a valid stage in an aggregation pipeline in MongoDB?

a)

$match

b)

$sort

c)

$join

d)

$group

7.

  1. Given the following document in a products collection:

{ "_id": ObjectId('5c8eccc1caa187d17ca6eea2'),

"name": "Laptop",

"price": 1200,

"category": "Electronics"}

What does the query db.products.find({ price: { $lt: 1500 } }) return?

a)

  • All documents with a price less than 1500.

b)

  • All documents with a price greater than 1500.

c)

  • All documents with a price equal to 1500.

d)

  • No documents, since $lt is not a valid operator.

8.

  1. What is the primary purpose of the $group stage in an aggregation pipeline?

a)

  • To sort documents in ascending or descending order.

b)

  • To filter documents based on a specific criterion.

c)

  • To group documents by a specific field and perform aggregate calculations.

d)

  • To limit the number of documents returned.

9.

  1. What is the output of the following aggregation pipeline?

db.orders.aggregate([

{ $match: { status: "completed" } },

{ $group: { _id: "$customerId", totalSpent: { $sum: "$amount" } } } ])

a)

  • The total sum of all completed orders.

b)

  • One document per customer with the total spent on completed orders.

c)

  • All completed orders without modifications.

d)

  • A single document with the total number of completed orders.

10.

  1. Which of the following aggregation stages is used to filter documents before grouping them?

a)

  • $project

b)

$match

c)

$group

d)

$sort