Top MongoDB Interview Questions and Answers

1. What makes MongoDB the best?
MongoDB is considered to be the best NoSQL database because of its following features:

  • Document-oriented (DO)
  • High performance (HP)
  • High availability (HA)
  • Easy scalability
  • Rich query language

2. How to do transactions/locking in MongoDB?
MongoDB does not use conventional locking with reduction as it is planned to be light, high-speed, and knowable in its presentation. It can be considered as parallel to the MySQL MyISAM auto entrust sculpt. With the simplest business sustain, performance is enhanced, particularly in a structure with numerous servers.

To get in-Depth knowledge on MongoDB you can enroll for live MongoDB Online Training

3. What is the role of profiler in MongoDB?
MongoDB includes a database profiler which shows performance characteristics of each operation against the database. With this profiler you can find queries (and write operations) which are slower than they should be and use this information for determining when an index is needed.

4. What is “Namespace” in MongoDB?
MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the collection. The concatenation of the collection name and database name is called a namespace.

5. While creating Schema in MongoDB what are the points need to be taken in consideration?

Points need to be taken in consideration are

  • Design your schema according to user requirements
  • Combine objects into one document if you use them together. Otherwise, separate them
  • Do joins while write, and not when it is on read
  • For most frequent use cases optimize your schema
  • Do complex aggregation in the schema

6. What is the syntax to create a collection and to drop a collection in MongoDB?

  • Syntax to create collection in MongoDB is db.createCollection(name,options)
  • Syntax to drop collection in MongoDB is db.collection.drop()

7. Explain can you move old files in the moveChunk directory?

Yes, it is possible to move old files in the moveChunk directory, during normal shard balancing operations these files are made as backups and can be deleted once the operations are done.

8. Which are the different languages supported by MongoDB?
MonggoDB provides official driver support for C, C++, C#, Java, Node.js, Perl, PHP, Python, Ruby, Scala, Go and Erlang.

You can use MongoDB with any of the above languages. There are some other community supported drivers too but the above mentioned ones are officially provided by MongoDB.

9. What type of DBMS is MongoDB?
MongoDB is a document oriented DBMS

10. Does MongoDB support primary-key, foreign-key relationship?
No. By Default, MongoDB doesn’t support primary key-foreign key relationship.

To get in-Depth knowledge on MongoDB you can enroll for live MongoDB Online Training

11. Explain the structure of ObjectID in MongoDB.
ObjectID is a 12-byte BSON type. These are:

  • 4 bytes value representing seconds
  • 3 byte machine identifier
  • 2 byte process id
  • 3 byte counter

12. Why 32 bit version of MongoDB are not preferred ?
Because MongoDB uses memory mapped files so when you run a 32-bit build of MongoDB, the total storage size of server is 2 GB. But when you run a 64-bit build of MongoDB, this provides virtually unlimited storage size. So 64-bit is preferred over 32-bit.

13. Explain what is GridFS in MongoDB?
For storing and retrieving large files such as images, video files and audio files GridFS is used. By default, it uses two files fs.files and fs.chunks to store the file’s metadata and the chunks.

14. What is Splitting in MongoDB?
Splitting is a background process that is used to keep chunks from growing too large.

15. Which are the storage engines used by MongoDB?
MMAPv1 and WiredTiger are two storage engine used by MongoDB.

16. Mention the command syntax that is used to view Mongo is using the link?
The command syntax that is used to view mongo is using the link is db._adminCommand(“connPoolStats.”)

17. When an object attribute is removed, is it deleted from the store?
Yes, you can remove the attribute and then re-save() the object.

18. How to configure the cache size for WiredTiger in MongoDB?
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.

19. In which format MongoDB represents document structure?
MongoDB uses BSON to represent document structures.

20. How do you see the connections used by Mongos?
The following command needs to be used: db._adminCommand(“connPoolStats”);

Take your career to new heights of success with an MongoDB Certification

#mongodb

Top MongoDB Interview Questions and Answers
1 Likes12.00 GEEK