Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the basic unit of data storage in MongoDB?
The basic unit of data storage in MongoDB is a document. Documents are similar to JSON objects and store data in key-value pairs.
Click to reveal answer
beginner
How are MongoDB documents structured?
MongoDB documents are structured as BSON (Binary JSON), which allows them to store complex data types like arrays and nested documents.
Click to reveal answer
intermediate
Can MongoDB documents have different fields in the same collection?
Yes, MongoDB is schema-less, so documents in the same collection can have different fields and structures.
Click to reveal answer
beginner
What data types can be stored inside a MongoDB document?
MongoDB documents can store various data types including strings, numbers, dates, arrays, embedded documents, and binary data.
Click to reveal answer
intermediate
Why does MongoDB use BSON instead of plain JSON for documents?
BSON is a binary format that is faster to parse and supports additional data types like date and binary which JSON does not support natively.
Click to reveal answer
What format does MongoDB use to store documents internally?
AYAML
BBSON
CCSV
DXML
✗ Incorrect
MongoDB stores documents internally in BSON format, which is a binary form of JSON.
Can documents in the same MongoDB collection have different fields?
ANo, all documents must have the same fields
BOnly if they are in different databases
CYes, MongoDB collections are schema-less
DOnly if they are indexed
✗ Incorrect
MongoDB collections are schema-less, so documents can have different fields and structures.
Which of the following is NOT a valid data type in a MongoDB document?
AArray
BDate
CEmbedded document
DFunction
✗ Incorrect
MongoDB documents do not store functions as data types.
Why is BSON preferred over JSON in MongoDB?
ABSON supports more data types and is faster to parse
BBSON is human-readable
CBSON is text-based
DBSON files are smaller than JSON files
✗ Incorrect
BSON supports additional data types and is optimized for speed, unlike JSON.
What does a MongoDB document resemble in everyday terms?
AA JSON object
BA spreadsheet row
CA flat text file
DA relational table
✗ Incorrect
A MongoDB document resembles a JSON object with key-value pairs.
Explain how MongoDB stores data as documents and why this is useful.
Think about how documents are like JSON and how MongoDB allows different structures.
You got /5 concepts.
Describe the advantages of using BSON for storing MongoDB documents compared to plain JSON.
Consider what extra features BSON has that JSON lacks.
You got /4 concepts.
Practice
(1/5)
1. What is the basic unit of data storage in MongoDB?
easy
A. A document
B. A table
C. A row
D. A column
Solution
Step 1: Understand MongoDB data structure
MongoDB stores data as documents, not tables or rows like traditional databases.
Step 2: Identify the correct data unit
The document is the flexible data unit that holds fields and values in MongoDB.
Final Answer:
A document -> Option A
Quick Check:
MongoDB data unit = document [OK]
Hint: Remember: MongoDB uses documents, not tables or rows [OK]
Common Mistakes:
Confusing documents with tables from SQL
Thinking rows or columns are used in MongoDB
Assuming collections are the basic unit
2. Which of the following is the correct way to represent a MongoDB document with a field name and value Alice?
easy
A. [ 'name': 'Alice' ]
B. { 'name' = 'Alice' }
C. { name: 'Alice' }
D. ( name: 'Alice' )
Solution
Step 1: Recall MongoDB document syntax
MongoDB documents use JSON-like syntax with curly braces and colon to assign values.
Step 2: Check each option's syntax
{ name: 'Alice' } uses correct JSON-like syntax: { name: 'Alice' }. Others use invalid symbols or brackets.
Final Answer:
{ name: 'Alice' } -> Option C
Quick Check:
Correct MongoDB document = JSON-like with colons [OK]
Hint: Use curly braces and colons for fields in MongoDB documents [OK]
Common Mistakes:
Using equal signs instead of colons
Using square or round brackets instead of curly braces
Putting field names in quotes incorrectly
3. Given the MongoDB document: { name: 'Bob', age: 30, hobbies: ['reading', 'swimming'] }, what is the value of the hobbies field?
medium
A. A string 'reading, swimming'
B. A nested document with keys 'reading' and 'swimming'
C. A number 2
D. An array with 'reading' and 'swimming'
Solution
Step 1: Identify the data type of hobbies field
The hobbies field is shown with square brackets, which means it is an array.
Step 2: Understand array contents
The array contains two string elements: 'reading' and 'swimming'.
Final Answer:
An array with 'reading' and 'swimming' -> Option D
Quick Check:
Square brackets mean array = An array with 'reading' and 'swimming' [OK]
Hint: Square brackets [] mean array in MongoDB documents [OK]
Common Mistakes:
Thinking it's a string instead of an array
Confusing arrays with nested documents
Assuming the value is a count of items
4. Identify the error in this MongoDB document: { 'title': 'Book', pages: 250, author: 'John Doe' }
medium
A. This document is valid and has no error
B. Mixing quoted and unquoted field names is invalid
C. Values must be numbers only
D. Field names must all be unquoted
Solution
Step 1: Check field name quoting rules
MongoDB allows field names to be quoted or unquoted as long as they are valid strings.
Step 2: Verify document validity
Mixing quoted and unquoted field names is allowed; values are correctly typed.
Final Answer:
This document is valid and has no error -> Option A
Quick Check:
Quoted or unquoted field names both valid [OK]
Hint: MongoDB allows mixed quoted/unquoted field names [OK]
Common Mistakes:
Thinking all field names must be quoted
Assuming mixing quotes causes error
Believing values must be only numbers
5. You want to store a user's profile with name, age, and a list of addresses (each with street and city) in MongoDB. Which document structure correctly represents this?