Recall & Review
beginner
What does an ascending index mean in MongoDB?
An ascending index sorts the values from smallest to largest (like A to Z or 1 to 10). It helps MongoDB find data quickly in that order.
Click to reveal answer
beginner
What does a descending index mean in MongoDB?
A descending index sorts the values from largest to smallest (like Z to A or 10 to 1). It helps MongoDB find data quickly in reverse order.
Click to reveal answer
beginner
How do you specify an ascending index on the field 'age' in MongoDB?
You create it by using: { age: 1 } where 1 means ascending order.
Click to reveal answer
beginner
How do you specify a descending index on the field 'score' in MongoDB?
You create it by using: { score: -1 } where -1 means descending order.
Click to reveal answer
intermediate
Does the direction of an index (ascending or descending) affect query speed in MongoDB?
No, MongoDB uses indexes efficiently in both ascending and descending directions. The direction mainly affects sorting order, not speed.
Click to reveal answer
In MongoDB, what does the value 1 mean when creating an index on a field?
✗ Incorrect
1 means ascending order when defining an index in MongoDB.
What value do you use to create a descending index on a field in MongoDB?
✗ Incorrect
-1 means descending order for an index in MongoDB.
If you want to sort query results from highest to lowest using an index, which index direction should you use?
✗ Incorrect
Descending index sorts values from highest to lowest.
Does MongoDB use ascending indexes to speed up descending sorts?
✗ Incorrect
MongoDB can use ascending indexes for descending sorts on single fields, but descending indexes are better for descending sorts.
Which of these is a valid MongoDB index definition for ascending order on 'name'?
✗ Incorrect
1 means ascending order in MongoDB index definitions.
Explain the difference between ascending and descending index directions in MongoDB and when you might use each.
Think about sorting order and how indexes help find data faster.
You got /5 concepts.
How do you define an ascending and a descending index on a field in MongoDB? Give the syntax.
Remember the numbers 1 and -1 represent direction.
You got /4 concepts.