0
0
MongoDBquery~20 mins

Collections vs tables mental model in MongoDB - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Collections vs Tables Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the basic difference between collections and tables
In MongoDB, what is the closest equivalent of a SQL table?
AA document
BA collection
CA field
DA database
Attempts:
2 left
💡 Hint
Think about where groups of similar data are stored.
query_result
intermediate
2: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 } })
ASELECT * FROM users WHERE age > 25;
BSELECT * FROM users WHERE age < 25;
Cdb.users.find({ age: { $lt: 25 } })
Ddb.users.find({ age: 25 })
Attempts:
2 left
💡 Hint
Look for the query that matches the condition 'age greater than 25'.
📝 Syntax
advanced
2:00remaining
Identifying the correct syntax for inserting data
Which MongoDB command correctly inserts a document with fields name and age into the users collection?
Adb.users.insert({ 'name': 'Alice', 'age': 30 })
BINSERT INTO users (name, age) VALUES ('Alice', 30);
Cdb.users.insertOne({ name: 'Alice', age: 30 })
Ddb.users.add({ name: 'Alice', age: 30 })
Attempts:
2 left
💡 Hint
MongoDB uses JavaScript-like commands for inserting one document.
optimization
advanced
2: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 })?
ACreate a text index on the <code>customerId</code> field
BCreate an index on the <code>orderDate</code> field
CCreate a unique index on the <code>orderId</code> field
DCreate an index on the <code>customerId</code> field
Attempts:
2 left
💡 Hint
Think about which field is used in the query filter.
🔧 Debug
expert
2: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?
AThe <code>price</code> field is stored as a string, not a number
BThe collection <code>products</code> does not exist
CThe query syntax is incorrect
DThe database is empty
Attempts:
2 left
💡 Hint
Think about how data types affect comparison operators.