- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
MongoDB Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to MongoDB Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
Answer : A
Explanation
The way SQL databases stores data rows in a table, MonngoDB stores documents inside collections.
Q 2 - Which of the following is true about sharding?
A - Sharding is enabled at the database level
B - Creating a sharded key automatically creates an index on the collection using that key
C - We cannot change a shard key directly/automatically once it is set up
Answer : C
Explanation
There is no direct way of changing the sharded key unless you dump the entire data, drop the sharded key and then re-import everything. Other all options are false. Sharding is enabled at collection level, it does not create any index by default and finally sharding environment supports regular sorting.
Q 3 - Which of the following is supported by MongoDB?
B - Relationships between Collections (Primary Key – Foreign Key)
Answer : C
Explanation
MongoDB does not support things like ACID Transactions or atomicity across collections or relationships like SQL.
Q 4 - Which option can be used with update command so that a new document gets created if no matching document is found based on the query condition?
A - Specify {upsert : true } as the third parameter of update command
B - upsert command instead of update command
C - {update: true, insert: true} as the third parameter of update command
Answer : A
Explanation
When you specify upsert: true for an update operation and no matching documents are found, MongoDB creates a new document.
Q 5 - Which type of indexes does MongoDB support?
Answer : D
Explanation
MongoDB supports all of the above mentioned indexes.
Q 6 - What is the equivalent command in MongoDB for the following SQL query?
SELECT * FROM posts WHERE author like "%john%"
A - db.posts.find( { author: /john/ } )
B - db.posts.find( { author: {$like: /john/} } )
Answer : A
Explanation
db.posts.find( { author: /john/ } )
Q 7 - Which of the following methods can be used in MongoDB for relation documents?
Answer : C
Explanation
Manual references where you save the _id field of one document in another document as a reference. DBRefs are references from one document to another using the value of the first document’s _id field, collection name, and, optionally, its database name.
Q 8 - What is a replica set node which does not maintain its own data but exists only for voting purpose called?
Answer : B
Explanation
We may add an extra mongod instance to a replica set as an arbiter. Arbiters do not maintain a data set. Arbiters only exist to vote in elections. If your replica set has an even number of members, add an arbiter to obtain a majority of votes in an election for primary. Arbiters do not require dedicated hardware
Q 9 - Which of the following aggregation query will sort the posts collection with author key ascending:
A - db.posts.aggregate([ {$sort:{ author:1 } } ])
B - db.posts.aggregate([ {$sort:{ author:-1 } } ])
C - db.posts.aggregate([ {author: {$sort: 1} } ])
D - You need to first use $group or $project or $match command before $sort in the pipeline
Answer : A
Explanation
In the aggregation pipeline, it is not necessary to have a $group or $project or $match before the $sort operation.
Q 10 - Which index is used to index the content stored in arrays?
Answer : A
Explanation
MongoDB uses multikey indexes to index the content stored in arrays. If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.
To Continue Learning Please Login
Login with Google