---
title: "MongoDB: NoSQL Database Fundamentals"
description: "Master NoSQL fundamentals, BSON document structure, and the MongoDB aggregation pipeline."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/mongodb-nosql-fundamentals-quiz
---

# MongoDB: NoSQL Database Fundamentals

Welcome to the MongoDB Basics Quiz! NoSQL databases changed the way we handle modern web scale data. Understanding the document model, the flexibility of BSON, and the power of the aggregation pipeline is key for any modern developer or DevOps professional. Let's see how much you know about the most popular document store in the world!

## Questions

### 1. What type of NoSQL database is MongoDB?

- Key-Value store
  - Redis is a key-value store; MongoDB is document-oriented.
- **Document-oriented** ✅
  - Correct! MongoDB stores data in flexible, JSON-like documents called BSON.
- Graph database
  - Neo4j is a graph database; MongoDB uses a document model.
- Column-family store
  - Cassandra is a column-family store.

**Hint:** Think about how data is stored.

### 2. What does "BSON" stand for in MongoDB?

- Base Serialized Object Notation
  - BSON is specifically the binary representation of JSON.
- **Binary JSON** ✅
  - Correct! BSON extends JSON to support more data types and efficient encoding.
- Boolean Serialized Object Network
  - Incorrect terminology.
- Buffered Standard Object Notation
  - Incorrect terminology.

**Hint:** The binary version of a popular format.

### 3. In MongoDB, what is the equivalent of a SQL "Table"?

- Database
  - A Database is a container that holds multiple Collections.
- **Collection** ✅
  - Correct! A collection is a group of documents, similar to a table in SQL.
- Document
  - A Document is the equivalent of a SQL "Row."
- Field
  - A Field is the equivalent of a SQL "Column."

**Hint:** A group of documents.

### 4. What is the purpose of the unique "_id" field in a document?

- To encrypt the sensitive fields within the document
  - Encryption is handled at the field level or storage level, not by the _id.
- **To act as a unique Primary Key for the document** ✅
  - Correct! Every document requires a unique _id to distinguish it from others.
- To index the document for full-text search engines
  - Full-text indexing is a separate feature; _id is for primary identification.
- To track the total number of versions of a document
  - Version tracking is not the primary purpose of the _id field.

**Hint:** Every document needs one.

### 5. Which command is used to insert a single document into a collection?

- db.collection.add()
  - The correct command in the modern MongoDB API is insertOne().
- **db.collection.insertOne()** ✅
  - Correct! This method inserts one document and returns an acknowledgment.
- db.collection.put()
  - PUT is an HTTP method; MongoDB uses specific insert methods.
- db.collection.create()
  - CREATE is used in SQL schemas; MongoDB uses insert commands for data.

**Hint:** Basic CRUD.

### 6. What does "Schema-less" mean in the context of MongoDB?

- The database does not require an underlying storage engine
  - MongoDB requires a storage engine like WiredTiger to manage disk writes.
- **Documents in a collection can have different fields and structures** ✅
  - Correct! MongoDB allows for flexible documents without a fixed, pre-defined schema.
- The database cannot be queried using traditional logical operators
  - MongoDB supports a wide range of logical and comparison operators.
- All data is stored in memory without being written to a disk
  - MongoDB is a persistent database that writes data to disk.

**Hint:** Flexible structure.

### 7. Which operator is used to filter results where a value is greater than a number?

- **$gt** ✅
  - Correct! The $gt operator finds documents with values greater than the specified amount.
- $gte
  - The $gte operator checks if a value is greater than OR equal to a number.
- $high
  - This is not a valid MongoDB query operator.
- $max
  - $max is an update or aggregation operator, not a comparison operator.

**Hint:** Short for Greater Than.

### 8. What is the "Aggregation Pipeline"?

- A backup utility for exporting collections to external files
  - That describes mongodump or mongoexport, not the aggregation pipeline.
- **A framework for data processing through multiple stages** ✅
  - Correct! It processes documents through stages like filtering, grouping, and transforming.
- A tool for performing real-time full-text searches across indices
  - While aggregation can include search, its primary role is data transformation.
- A specialized index for high-speed geospatial queries
  - Geospatial queries use specific 2dsphere or 2d indexes.

**Hint:** Multi-stage processing.

### 9. Which aggregation stage is used to filter documents?

- $filter
  - While logical, $filter is an array operator; the pipeline stage is $match.
- **$match** ✅
  - Correct! The $match stage filters documents to allow only those that match a condition.
- $where
  - $where is used in standard queries for JavaScript expressions, not as a pipeline stage.
- $find
  - find() is a top-level query method, not an aggregation stage.

**Hint:** Matches conditions.

### 10. What does the "$group" stage do in an aggregation pipeline?

- It sorts the output documents by a specified field
  - Sorting is performed by the $sort stage.
- **It aggregates documents by a key and applies calculations** ✅
  - Correct! It groups documents to calculate totals, averages, or other metrics.
- It merges two separate collections into a single stream
  - Merging collections is typically handled by $lookup or $unionWith.
- It creates a new collection based on the results of the pipeline
  - Writing results to a collection is the role of the $out or $merge stages.

**Hint:** Summarizing data.

### 11. Which operator is used to update a specific field in a document?

- $update
  - update() is the method; $set is the operator used within that method.
- **$set** ✅
  - Correct! The $set operator replaces the value of a field or creates it if it doesn’t exist.
- $put
  - $put is not a valid operator in MongoDB; it is an HTTP verb.
- $assign
  - MongoDB uses $set for assigning values to fields.

**Hint:** Assigning a value.

### 12. What is "Horizontal Scaling" (Sharding) in MongoDB?

- Adding more CPU and RAM to a single database server
  - This is Vertical Scaling (Scaling Up), which has physical limits.
- **Distributing data across multiple machines for high throughput** ✅
  - Correct! Sharding allows MongoDB to scale out by partitioning data across clusters.
- Replicating the same dataset across multiple backup nodes
  - This describes Replication, which provides High Availability rather than scaling.
- Splitting large documents into smaller individual collections
  - This is a data modeling choice (normalization) rather than an infrastructure scaling strategy.

**Hint:** Spreading data across servers.

### 13. What is a "Replica Set"?

- A set of indices created to optimize a specific query
  - Indices optimize reads; replica sets provide data redundancy.
- **A group of MongoDB instances maintaining the same data set** ✅
  - Correct! Replica sets ensure high availability and data redundancy.
- A collection of documents used for testing new schemas
  - Replica sets are an infrastructure configuration, not a data container.
- A series of automated backups stored in a remote region
  - Backups are snapshots; a replica set is a live, synchronized group of nodes.

**Hint:** High Availability (HA).

### 14. Which command is used to find all documents in a collection?

- db.collection.search({})
  - MongoDB does not have a search() method; it uses find().
- **db.collection.find({})** ✅
  - Correct! An empty filter {} instructs MongoDB to return every document in the collection.
- db.collection.all()
  - The standard method for retrieving all documents is find({}).
- db.collection.fetch()
  - fetch() is not a valid MongoDB collection method.

**Hint:** Search.

### 15. What does the "$lookup" stage perform?

- It searches the collection for a specific string pattern
  - Pattern matching is handled by the $regex operator in a $match stage.
- **It performs a left outer join to another collection** ✅
  - Correct! It allows you to combine documents from different collections in the same database.
- It checks the system logs for database performance issues
  - Performance monitoring is handled by tools like Compass or Atlas, not $lookup.
- It validates the document structure against a schema
  - Schema validation is a collection-level setting, not an aggregation stage.

**Hint:** The NoSQL version of a Join.

### 16. How do you perform a "Delete" in MongoDB?

- db.collection.removeDocuments()
  - The standard modern methods are deleteOne() and deleteMany().
- **db.collection.deleteMany({})** ✅
  - Correct! This removes all documents that match the provided filter.
- db.collection.drop()
  - drop() removes the entire collection and its indexes, not just the documents.
- db.collection.truncate()
  - TRUNCATE is a SQL command; MongoDB uses delete methods.

**Hint:** Removing documents.

### 17. What is an "Index" in MongoDB?

- A log of all administrative changes made to the schema
  - Administrative changes are logged in the audit log, not an index.
- **A data structure that improves the speed of retrieval** ✅
  - Correct! Indexes allow MongoDB to find documents without scanning the entire collection.
- A mapping of physical disk locations to document IDs
  - While related to storage, an index is a high-level structure used for query optimization.
- A tool for managing user permissions and access levels
  - Access control is managed via Roles and Privileges.

**Hint:** Speeding up reads.

### 18. What is the "$unwind" stage used for?

- To compress large documents to save storage space
  - Compression is handled by the storage engine, not an aggregation stage.
- **To output a document for each element in an array field** ✅
  - Correct! It "flattens" arrays by creating a separate document for each array element.
- To reverse the order of documents in a result set
  - Reversing or ordering is the job of the $sort stage.
- To remove a specific field from all documents
  - Removing fields is done using the $project or $unset stages.

**Hint:** Dealing with arrays.

### 19. What is the "Primary" node in a Replica Set?

- The node with the highest hardware specifications
  - Hardware doesn’t determine the primary; it is chosen by an election process.
- **The node that receives all write operations** ✅
  - Correct! All writes go to the primary, which then replicates them to secondaries.
- The node that is used exclusively for long-term backups
  - Secondaries or hidden nodes are typically used for backups, not the primary.
- The node that manages the sharding metadata
  - Metadata for sharding is managed by Config Servers, not the Replica Set Primary.

**Hint:** The leader.

### 20. Which operator is used to push an element into an array field?

- $add
  - In MongoDB, $add is used for mathematical addition in aggregation pipelines.
- **$push** ✅
  - Correct! $push appends a value to an existing array field.
- $append
  - The correct operator name is $push.
- $insert
  - The operator for adding array elements is $push.

**Hint:** Adding to a list.

### 21. What is the purpose of the "sort()" method?

- To filter the results based on a logical condition
  - Filtering is handled by find() or $match, not sort().
- **To determine the order of returned matching documents** ✅
  - Correct! It specifies how the result set should be ordered (ascending or descending).
- To group identical documents into a single summary
  - Grouping is handled by the aggregation pipeline $group stage.
- To limit the number of fields returned per document
  - Selecting specific fields is called projection, handled by the second argument of find().

**Hint:** Ordering results.

### 22. What is "Atlas" in the MongoDB ecosystem?

- A tool for visualizing the geographic location of nodes
  - While "Atlas" sounds geographic, it is the name of the managed cloud service.
- **A fully managed cloud database service** ✅
  - Correct! MongoDB Atlas is a DBaaS that automates management and deployment.
- A command-line utility for database performance tuning
  - Performance tuning is done via the shell or specialized tools, not "Atlas."
- A library for mapping Go structs to MongoDB documents
  - That describes an ODM (Object Document Mapper) like BSON tags or mongo-go-driver.

**Hint:** Cloud service.

### 23. Which stage is used to rename fields in an aggregation pipeline?

- $rename
  - $rename is an update operator; in aggregation, $project is used to rename fields.
- **$project** ✅
  - Correct! $project reshapes documents, allowing for field inclusion or renaming.
- $reshape
  - $reshape is not a valid aggregation pipeline stage.
- $map
  - $map is an expression used for arrays, not a stage for renaming document fields.

**Hint:** Reshaping the output.

### 24. What does "TTL Index" stand for?

- Total Transaction Log
  - Incorrect terminology.
- **Time To Live Index** ✅
  - Correct! It specifies when documents should be automatically deleted from a collection.
- Transfer Table Level
  - Incorrect terminology.
- Tagged Terminal Layer
  - Incorrect terminology.

**Hint:** Automatic deletion.

### 25. What is a "Capped Collection"?

- A collection with a password-protected access layer
  - Security is handled by RBAC, not by collection type.
- **A fixed-size collection that overwrites oldest entries** ✅
  - Correct! Once full, it behaves like a circular buffer by overwriting old data.
- A collection that prevents any new fields from being added
  - This describes schema validation or "locked" schemas, not a capped collection.
- A collection used exclusively for storing small binary files
  - Binary files are usually stored in GridFS; capped collections are for fixed-size logging.

**Hint:** Fixed size.

### 26. Which operator checks if a field exists in a document?

- $has
  - The correct MongoDB operator for existence checks is $exists.
- **$exists** ✅
  - Correct! It filters documents based on whether a specific field is present.
- $is
  - Not a valid MongoDB operator.
- $check
  - Not a valid MongoDB operator.

**Hint:** Existence check.

### 27. What is the "Compass" tool?

- A terminal-based tool for exploring sharded clusters
  - Compass is a graphical user interface, not a terminal tool.
- **A graphical user interface for visualizing MongoDB data** ✅
  - Correct! It is the official GUI for exploring and managing MongoDB data.
- A migration tool for moving data from SQL to NoSQL
  - Migration is handled by specialized drivers or tools like mongoimport.
- A cloud-based dashboard for monitoring server uptime
  - Uptime monitoring is a feature of MongoDB Atlas, while Compass is for data exploration.

**Hint:** GUI for MongoDB.

### 28. What does the "upsert" option do in an update operation?

- It creates a backup of the document before modifying it
  - Backups must be performed separately; upsert is for conditional insertion.
- **It creates a new document if no match is found** ✅
  - Correct! It performs an update if a match exists, otherwise it inserts a new document.
- It sorts the document fields in alphabetical order
  - Upsert is about data insertion/updating, not about field ordering.
- It prevents the document from being updated by others
  - This describes locking or isolation levels, not the upsert operation.

**Hint:** Update or Insert.

### 29. Which command shows the performance statistics of a query?

- **explain()** ✅
  - Correct! This method provides information on the query plan and execution statistics.
- analyze()
  - SQL uses ANALYZE; MongoDB uses explain().
- profile()
  - The database profiler collects data on operations, but .explain() is used for specific queries.
- stats()
  - stats() provides information about the collection or database size, not the query plan.

**Hint:** Analysing speed.

### 30. What is "Write Concern"?

- A diagnostic report detailing slow write operations
  - Slow writes are tracked in the slow query log, not via write concern.
- **A setting specifying the level of acknowledgment for writes** ✅
  - Correct! It determines how many nodes must confirm a write before it is considered successful.
- A security policy that restricts write access to specific users
  - Access control is handled by RBAC, not by write concern settings.
- A validation rule that checks data types during an insert
  - Data type validation is part of Schema Validation.

**Hint:** Confirmation of success.
