MongoDB Interview Questions

  1. What is MongoDB ?

    MongoDB is a document based NoSQL Database.

  2. Why is MongoDB, a NoSQL Database ?

    A NoSQL Database is one that provides mechanism for storage and retrieval of data that is modeled in means other than tabular relations. Since MongoDB provides a document based (which is again a set of key-value pairs) that is schema-less, MongoDB is a NoSQL Database. And to mention, key-value stores are the simplest NoSQL Databases and MongoDB is popular among them.

  3. Could you mention some NoSQL Databases other than MongoDB ?

    Yes. Of course, there are many. Some of the notable ones are Cassandra, HBASE, CouchDB, IBM Informix, Azure DocumentDB, ToroDB etc.

  4. What are the equivalents of Tables and Rows in SQL to that of MongoDB ?

    MongoDB Collections could be considered as equivalent to Tables and MongoDB Documents could be considered as equivalent to Row of SQL.

  5. What specification does MongoDB Document follow ?

    MongoDB Document follows BSON (Binary JSON) Specification.

  6. What are the data types that are allowed for values in key:value pairs of documents.

    MongoDB Document follows BSON (Binary JSON) Specification. And the data types allowed are all those that are specified in BSON specification.

  7. What should be done when you have to work with large datasets and high data throughput ?

    MongoDB is horizontally scalable. If the application is expected to handle large datasets and high data throughput, you may add required number of computers (/nodes) to the cluster.

  8. Is there something like primary key in MongoDB ?

    There is no concept of primary key in MongoDB. But there is a key:value pair with key as _id that is used to store a unique value for each Document that is inserted to Collection. By default _id is populated by MongoDB. But _id:value could be provided by user also, as long as the user provides unique value for _id.

  9. Coming to Collections, do you think that they can be restricted in size ?

    Yes. During the creation of collection, we may specify the size limit in Bytes, ie., the number of bytes that can go into that collection. These are also called capped collections. And when we say size, it includes all the data and metadata.

  10. Is MongoDB fault tolerant ?

    Yes. Data Redundancy could be achieved with the help of Replica Set. With MongoDB Replica Set, data could be replicated over specified number of nodes in the cluster. And during that scenario, even if a node fails, there are others with data replicated already. Although, it has to be noted that if a transaction is stored in a DB and just before replicating it to others the node goes down, the transaction data is lost. This is unavoidable with MongoDB.

  11. Can MongoDB be used for real time analytics ?

    Yes. MongoDB’s low latency and ability to analyze semi-structured or unstructured data make it as really a good choice for real time analytics.

Conclusion :

In this MongoDB Tutorial, we have learnt some MongoDB Interview Questions & Answers.