1. Which type of database is MongoDB?
- a) Relational Database
- b) Document Database
- c) Key-Value Store
- d) Graph Database
Test your knowledge of Database - [MongoDB] section with these interactive multiple-choice questions.
1. Which type of database is MongoDB?
2. What is the default port for MongoDB?
3. Which command shows all databases in MongoDB?
show dbs and show databases display all databases.
4. What is the format of data storage in MongoDB?
5. Which operator is used to update existing fields in MongoDB?
$set updates the value of a field.
6. What is the primary key in MongoDB called?
_id field as primary key.
7. Which method inserts multiple documents in MongoDB?
insertMany() inserts multiple documents at once.
8. What does the $lookup operator do?
$lookup performs a left outer join between collections.
9. Which command starts the MongoDB shell?
mongo command starts the MongoDB shell.
10. What is sharding in MongoDB?
11. Which index type ensures field values are unique?
12. What is the purpose of the $group stage in aggregation?
$group groups input documents by specified identifier.
13. Which method removes a document in MongoDB?
deleteOne() and remove() can delete documents (though remove() is deprecated).
14. What is a replica set in MongoDB?
15. Which operator checks if a field exists?
{ field: { $exists: true } } matches documents where the field exists.
16. What is the purpose of the $match stage in aggregation?
$match filters documents like the find() method.
17. Which command creates an index in MongoDB?
createIndex() creates indexes to improve query performance.
18. What does the $in operator do?
{ field: { $in: [value1, value2] } } matches documents where field equals any value in the array.
19. Which method returns a cursor in MongoDB?
find() returns a cursor to iterate through results.
20. What is the purpose of the explain() method?
explain() provides information on query execution plans.