MongoDB Quiz ( Beginner ) - All Questions
This beginner-level MongoDB quiz is designed for learners who want to understand the fundamentals of MongoDB and NoSQL databases. It covers core concepts like collections, documents, CRUD operations, data types, and basic commands, making it ideal for interviews and practice.
Question 1: What type of database is MongoDB?
- Relational database
- Graph database
- NoSQL document database
- Key-value database
Explanation: MongoDB is a NoSQL document-oriented database.
Question 2: MongoDB stores data in which format?
Explanation: MongoDB stores data in BSON, a binary JSON format.
Question 3: What is a database in MongoDB?
- A group of tables
- A group of collections
- A group of rows
- A group of schemas
Explanation: A MongoDB database contains collections.
Question 4: What is a collection in MongoDB?
- A group of documents
- A group of databases
- A group of rows
- A group of indexes
Explanation: Collections store documents in MongoDB.
Question 5: What is a document in MongoDB?
- A row in a table
- A JSON-like data record
- A schema definition
- A stored procedure
Explanation: Documents are JSON-like records stored in collections.
Question 6: Which field is mandatory in every MongoDB document?
Explanation: Every document must have a unique _id field.
Question 7: Which command shows all databases?
- show collections
- show dbs
- list dbs
- db.show()
Explanation: show dbs lists all available databases.
Question 8: Which command switches to a database?
- select db
- open db
- use database
- use <dbName>
Explanation: use <dbName> switches or creates a database.
Question 9: Which command displays the current database?
- currentDb()
- db.name()
- db
- show current
Explanation: db shows the current database.
Question 10: Which command lists collections in a database?
- show tables
- show collections
- list collections
- db.collections()
Explanation: show collections lists all collections.
Question 11: Which command inserts a single document?
- insertOne()
- insert()
- addOne()
- create()
Explanation: insertOne() inserts one document.
Question 12: Which command inserts multiple documents?
- insertMany()
- insertAll()
- addMany()
- bulkInsert()
Explanation: insertMany() inserts multiple documents.
Question 13: Which command retrieves all documents from a collection?
- findAll()
- fetch()
- select()
- find()
Explanation: find() retrieves documents from a collection.
Question 14: Which operation updates existing documents?
- modify()
- update()
- change()
- edit()
Explanation: update operations modify existing documents.
Question 15: Which method deletes documents?
- remove()
- deleteOne()
- delete()
- erase()
Explanation: deleteOne() removes a single document.
Question 16: Which operator is used to match values?
Explanation: $eq matches equal values.
Question 17: Which operator updates a field value?
Explanation: $set updates field values.
Question 18: Which operator increments numeric values?
Explanation: $inc increments numeric fields.
Question 19: Which operator adds elements to an array?
Explanation: $push adds elements to arrays.
Question 20: Which command removes all documents from a collection?
- drop()
- deleteAll()
- remove({})
- clear()
Explanation: remove({}) deletes all documents.
Question 21: Which command deletes an entire collection?
- drop()
- remove()
- delete()
- clear()
Explanation: drop() deletes the entire collection.
Question 22: Which data type is NOT supported in MongoDB?
- String
- Boolean
- Array
- Pointer
Explanation: Pointer is not a MongoDB data type.
Question 23: Which data type stores true or false?
Explanation: Boolean stores true or false values.
Question 24: Which command limits the number of results?
- skip()
- limit()
- restrict()
- cap()
Explanation: limit() restricts the number of documents returned.
Question 25: Which command skips a number of documents?
- ignore()
- offset()
- skip()
- jump()
Explanation: skip() skips specified documents.
Question 26: Which method sorts query results?
- order()
- sort()
- arrange()
- group()
Explanation: sort() orders query results.
Question 27: Which value sorts in ascending order?
Explanation: 1 represents ascending order.
Question 28: Which value sorts in descending order?
Explanation: -1 represents descending order.
Question 29: Which command counts documents?
- total()
- size()
- count()
- length()
Explanation: count() returns the number of documents.
Question 30: Which command creates an index?
- addIndex()
- createIndex()
- index()
- makeIndex()
Explanation: createIndex() creates an index.
Question 31: What is the default index created by MongoDB?
Explanation: MongoDB automatically indexes _id.
Question 32: Which feature improves query performance?
- Replication
- Indexes
- Sharding
- Schemas
Explanation: Indexes improve query speed.
Question 33: What is sharding in MongoDB?
- Data encryption
- Horizontal data partitioning
- Vertical scaling
- Backup process
Explanation: Sharding distributes data across servers.
Question 34: What is replication in MongoDB?
- Data duplication for high availability
- Data deletion
- Index creation
- Query optimization
Explanation: Replication ensures data availability.
Question 35: Which command shows query execution plan?
- explain()
- analyze()
- plan()
- debug()
Explanation: explain() shows query execution details.
Question 36: Which method updates only one document?
- updateMany()
- update()
- updateOne()
- modifyOne()
Explanation: updateOne() updates a single document.
Question 37: Which method updates multiple documents?
- updateAll()
- updateMany()
- modify()
- bulkUpdate()
Explanation: updateMany() updates multiple documents.
Question 38: Which operator checks for greater than?
Explanation: $gt means greater than.
Question 39: Which operator checks for less than?
Explanation: $lt means less than.
Question 40: Which operator checks for not equal?
Explanation: $ne checks for not equal values.
Question 41: Which operator performs logical AND?
Explanation: $and performs logical AND.
Question 42: Which operator performs logical OR?
Explanation: $or performs logical OR.
Question 43: Which operator matches array elements?
- $array
- $elemMatch
- $match
- $inArray
Explanation: $elemMatch matches array elements.
Question 44: Which command removes the current database?
- dropDatabase()
- removeDb()
- deleteDb()
- clearDb()
Explanation: dropDatabase() deletes the current database.
Question 45: Which tool is used to interact with MongoDB from terminal?
- mongo shell
- mongod
- mongodb service
- mongo driver
Explanation: Mongo shell allows terminal interaction.
Question 46: Which service runs the MongoDB server?
- mongo
- mongodb
- mongod
- mongosh
Explanation: mongod is the MongoDB server process.
Question 47: Which language is MongoDB query syntax based on?
Explanation: MongoDB queries are JavaScript-based.
Question 48: What is the main advantage of MongoDB?
- Fixed schema
- Flexible schema design
- Complex joins
- Strict relationships
Explanation: MongoDB offers flexible schema design.