MongoDB interview questions

MongoDB quiz questions

  • 1.

    Is there any need to create database command in MongoDB?

    Answer:

    You don't need to create a database manually in MongoDB because it creates automaically when you save the value into the defined collection at first time.

    For more information: click here

    View
  • 2.

    What is the difference between MongoDB and Cassandra?

    Answer:

    Difference between MongoDB and Cassandra:

    • MongoDB is cross-platform document-oriented database system while Cassandra is high performance distributed database system.
    • MongoDB is written in C++ while Cassandra is written in Java.
    • MongoDB is easy to administer in the case of failure while Cassandra provides high availability with no single point of failure.

    For more information: click here

    View
  • 3.

    What is the difference between MongoDB and CouchDB?

    Answer:

    Difference between MongoDB and CouchDB:

    • MongoDB is faster than CouchDB while CouchDB is safer than MongoDB.
    • Triggers are not available in MongoDB while triggers are available in CouchDB.
    • MongoDB serializes JSON data to BSON while CouchDB doesn't store data in JSON format.

    For more information: click here

    View
  • 4.

    What is the difference between MongoDB and Redis database?

    Answer:

    Difference between MongoDB and Redis:

    • Redis is faster than MongoDB.
    • Redis has a key-value storage whereas MongoDB has a document type storage.
    • Redis is hard to code but MongoDB is easy.

    For more information: click here

    View
  • 5.

    How does MongoDB provide concurrency?

    Answer:

    MongoDB uses reader-writer locks for concurrency. Reader-writer locks allow concurrent readers shared access to a resource, such as a database or collection, but give exclusive access to a single write operation.

    View
  • 6.

    How to configure the cache size for WiredTiger in MongoDB?

    Answer:

    For the WiredTiger storage engine, you can specify the maximum size of the cache that WiredTiger will use for all data. This can be done using storage.wiredTiger.engineConfig.cacheSizeGB option.

    View
  • 7.

    Is it possible to configure the cache size for MMAPv1 in MongoDB?

    Answer:

    No. it is not possible to configure the cache size for MMAPv1 because MMAPv1 does not allow configuring the cache size.

    View
  • 8.

    What is the usage of profiler in MongoDB?

    Answer:

    A database profiler is used to collect data about MongoDB write operations, cursors, database commands on a running mongod instance. You can enable profiling on a per-database or per-instance basis.

    The database profiler writes all the data it collects to the system. profile collection, which is a capped collection.

    View
  • 9.

    Which are the storage engines used by MongoDB?

    Answer:

    MMAPv1 and WiredTiger are two storage engine used by MongoDB.

    View
  • 10.

    What is a storage engine in MongoDB?

    Answer:

    A storage engine is the part of a database that is used to manage how data is stored on disk.

    For example: one storage engine might offer better performance for read-heavy workloads, and another might support a higher-throughput for write operations.

    View
  • 11.

    Why are MongoDB data files large in size?

    Answer:

    MongoDB doesn't follow file system fragmentation and pre allocates data files to reserve space while setting up the server. That's why MongoDB data files are large in size.

    View
  • 12.

    What will happen when you remove a document from database in MongoDB? Does MongoDB remove it from disk?

    Answer:

    Yes. If you remove a document from database, MongoDB will remove it from disk too.

    View
  • 13.

    In which format MongoDB represents document structure?

    Answer:

    MongoDB uses BSON to represent document structures.

    View
  • 14.

    What is CRUD in MongoDB?

    Answer:

    MongoDB supports following CRUD operations:

    • Create
    • Read
    • Update
    • Delete
    View
  • 15.

    By default, which replica sets are used to write data?

    Answer:

    By default, MongoDB writes data only to the primary replica set.

    View
  • 16.

    What is primary and secondary replica set in MongoDB?

    Answer:

    In MongoDB, primary nodes are the node that can accept write. These are also known as master nodes. The replication in MongoDB is single master so, only one node can accept write operations at a time.

    Secondary nodes are known as slave nodes. These are read only nodes that replicate from the primary.

    View
  • 17.

    What is replica set in MongoDB?

    Answer:

    A replica can be specified as a group of mongo instances that host the same data set. In a replica set, one node is primary, and another is secondary. All data is replicated from primary to secondary nodes.

    View
  • 18.

    What is sharding in MongoDB?

    Answer:

    In MongoDB, Sharding is a procedure of storing data records across multiple machines. It is a MongoDB approach to meet the demands of data growth. It creates horizontal partition of data in a database or search engine. Each partition is referred as shard or database shard.

    View
  • 19.

    What is the importance of covered query?

    Answer:

    Covered query makes the execution of the query faster because indexes are stored in RAM or sequentially located on disk. It makes the execution of the query faster.

    Covered query makes the fields are covered in the index itself, MongoDB can match the query condition as well as return the result fields using the same index without looking inside the documents.

    View
  • 20.

    Explain the covered query in MongoDB.

    Answer:

    A query is called covered query if satisfies the following two conditions:

    • The fields used in the query are part of an index used in the query.
    • The fields returned in the results are in the same index.
    View

© 2017 QuizBucket.org