Challenge - 5 Problems
Collections vs Tables Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding the basic difference between collections and tables
In MongoDB, what is the closest equivalent of a SQL table?
Attempts:
2 left
💡 Hint
Think about where groups of similar data are stored.
✗ Incorrect
A collection in MongoDB is similar to a table in SQL. Both store groups of related data entries.
❓ query_result
intermediate2:00remaining
Querying documents in a collection vs rows in a table
Given a MongoDB collection named
users with documents containing name and age, which query returns all users older than 25?MongoDB
db.users.find({ age: { $gt: 25 } })Attempts:
2 left
💡 Hint
Look for the query that matches the condition 'age greater than 25'.
✗ Incorrect
The MongoDB query db.users.find({ age: { $gt: 25 } }) matches the SQL query SELECT * FROM users WHERE age > 25; because both filter for age greater than 25.
📝 Syntax
advanced2:00remaining
Identifying the correct syntax for inserting data
Which MongoDB command correctly inserts a document with fields
name and age into the users collection?Attempts:
2 left
💡 Hint
MongoDB uses JavaScript-like commands for inserting one document.
✗ Incorrect
The correct MongoDB command to insert one document is insertOne(). Option C uses deprecated insert() which still works but is not recommended. Option C is SQL syntax. Option C is invalid.
❓ optimization
advanced2:00remaining
Choosing the best index for fast queries
You have a MongoDB collection
orders with many documents. You often query orders by customerId. Which index improves query speed for db.orders.find({ customerId: 123 })?Attempts:
2 left
💡 Hint
Think about which field is used in the query filter.
✗ Incorrect
Indexing the customerId field speeds up queries filtering by that field. Indexing unrelated fields or using text indexes on numeric fields won't help.
🔧 Debug
expert2:00remaining
Diagnosing a query that returns no results
You run
db.products.find({ price: { $gt: 100 } }) but get no results, even though you know some products have price over 100. What is the most likely reason?Attempts:
2 left
💡 Hint
Think about how data types affect comparison operators.
✗ Incorrect
If price is stored as a string, numeric comparison operators like $gt won't work as expected, causing no matches.