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 BSON in MongoDB?
BSON is a binary format used by MongoDB to store data. It is like JSON but includes extra data types and is faster for computers to read and write.
Click to reveal answer
beginner
Name three common BSON data types.
Common BSON data types include String (text), Int32 (small whole numbers), and Date (date and time).
Click to reveal answer
beginner
What BSON type would you use to store true or false values?
You use the Boolean BSON type to store true or false values.
Click to reveal answer
intermediate
How does BSON handle binary data like images or files?
BSON uses the Binary data type to store binary data such as images or files inside the database.
Click to reveal answer
intermediate
Why does BSON include special types like ObjectId and Date?
BSON includes special types like ObjectId to uniquely identify documents and Date to store time information efficiently, which JSON does not support natively.
Click to reveal answer
Which BSON data type is used to store text?
AString
BInt32
CBoolean
DBinary
✗ Incorrect
The String type stores text data in BSON.
What BSON type uniquely identifies a document in MongoDB?
AObjectId
BDouble
CBoolean
DDate
✗ Incorrect
ObjectId is a special BSON type used as a unique ID for documents.
Which BSON type would you use to store a true or false value?
AString
BBoolean
CInt64
DArray
✗ Incorrect
Boolean stores true or false values in BSON.
How does BSON store date and time information?
AAs a String
BAs an Int32
CUsing the Date type
DUsing Binary
✗ Incorrect
BSON has a special Date type to store date and time efficiently.
Which BSON type is best for storing images or files?
ABoolean
BString
CObjectId
DBinary
✗ Incorrect
Binary type stores raw binary data like images or files.
List and describe at least five BSON data types and their uses.
Think about text, numbers, true/false, time, unique IDs, and files.
You got /6 concepts.
Explain why BSON is used in MongoDB instead of plain JSON.
Consider what JSON cannot do well that BSON can.
You got /5 concepts.
Practice
(1/5)
1. Which BSON data type is used to store a unique identifier for documents in MongoDB?
easy
A. Date
B. String
C. ObjectId
D. Boolean
Solution
Step 1: Understand the purpose of ObjectId
ObjectId is a special BSON type designed to uniquely identify documents in MongoDB collections.
Step 2: Compare with other types
String stores text, Boolean stores true/false, Date stores time values. None of these uniquely identify documents like ObjectId.
Final Answer:
ObjectId -> Option C
Quick Check:
BSON unique ID = ObjectId [OK]
Hint: Unique document IDs in MongoDB are ObjectIds [OK]
Common Mistakes:
Confusing String with ObjectId for unique IDs
Thinking Boolean can identify documents
Assuming Date stores unique identifiers
2. Which of the following is the correct BSON data type to store a true or false value in MongoDB?
easy
A. Integer
B. Boolean
C. String
D. Array
Solution
Step 1: Identify the BSON type for true/false
Boolean is the BSON data type used to store true or false values.
3. Given the following MongoDB document: { "name": "Alice", "age": 30, "member": true } What BSON data types are used for the fields name, age, and member respectively?
medium
A. String, Boolean, Integer
B. String, String, Boolean
C. ObjectId, Integer, Boolean
D. String, Integer, Boolean
Solution
Step 1: Identify each field's value type
"name" is text, so String; "age" is a number, so Integer; "member" is true/false, so Boolean.
Hint: Match field values to String, Integer, Boolean types [OK]
Common Mistakes:
Confusing Integer with String for numbers
Mixing Boolean and Integer types
Assuming ObjectId for name field
4. You try to insert this document into MongoDB: { "date": "2023-01-01" } But you want the date field to be stored as a BSON Date type. What is the issue and how to fix it?
medium
A. The date is a string; convert it to BSON Date using ISODate()
B. The date is missing; add a date field
C. The date format is invalid; use YYYY/DD/MM instead
D. MongoDB does not support Date type; use String instead
Solution
Step 1: Identify the current data type of date field
The date is stored as a string because it is enclosed in quotes.
Step 2: Convert string to BSON Date type
Use MongoDB's ISODate() function to store the date as BSON Date type.
Final Answer:
The date is a string; convert it to BSON Date using ISODate() -> Option A
Quick Check:
Date string needs ISODate() for BSON Date [OK]
Hint: Use ISODate() to store dates, not strings [OK]
Common Mistakes:
Assuming string is automatically Date
Changing date format incorrectly
Believing MongoDB lacks Date type
5. You want to store a list of tags for a blog post in MongoDB. Which BSON data type should you use to store multiple tag strings together?
hard
A. Array
B. ObjectId
C. Boolean
D. Date
Solution
Step 1: Understand the need to store multiple values
A list of tags means multiple values grouped together.
Step 2: Identify BSON type for multiple values
Array is the BSON type used to store lists or collections of values.