MongoDB INTERVIEW QUESTION CHEATSHEET

MongoDB is becoming the most popular database and many popular websites use MongoDB. So, here is a collection of the most asked #MongoDB interview questions.

Please RT for reach and bookmark for easy recall.

🧵THREAD🧵

#100DaysOfCode
1. What kind of NoSQL database MongoDB is?

MongoDB is a document-oriented database. It stores data in the form of BSON structure-based documents. These documents are stored in a collection.

#100DaysOfCode
2. Which are the most important features of MongoDB?

The flexible data model in form of documents
Agile and highly scalable database
Faster than traditional databases
Expressive query language

#100DaysOfCode
3. What is a Namespace in MongoDB?

A Namespace is the concatenation of the database name and collection name. For e.g. school.students with the school as the database and students as the collection

#100DaysOfCode
4. Which languages can be used with MongoDB?

Currently, MongoDB provides official driver support for C, C++, C#, Java, Node.js, Perl, PHP, Python, Ruby, Scala, Go, and Erlang. MongoDB can easily be used with any of these languages.

#100DaysOfCode
5. Compare SQL databases and MongoDB at a high level.

SQL databases store data in form of tables, rows, columns, and records. MongoDB in contrast uses a flexible structure that can be easily modified and extended.

#100DaysOfCode
6. How is MongoDB better than other SQL databases?

MongoDB allows a highly flexible and scalable document structure. Also, MongoDB databases are faster as compared to SQL databases due to efficient indexing and storage techniques.

#100DaysOfCode
7. Compare MongoDB and CouchDB at a high level.

Both of these databases are document-oriented, MongoDB is a better choice for applications that need dynamic queries and good performance On the other side, CouchDB is better used for applications with occasionally changing queries
8. Does MongoDB need a lot of RAM?

No. MongoDB can be run even on a small amount of RAM. MongoDB dynamically allocates and de-allocates RAM based on the requirements of other processes.

#100DaysOfCode
9. Does MongoDB push the writes to disk immediately or lazily?

MongoDB pushes the data to disk lazily. It updates the immediately written to the journal but writing the data from journal to disk happens lazily.

#100DaysOfCode
10. Explain the structure of ObjectID in MongoDB.

ObjectID is a 12-byte BSON type with:

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

#100DaysOfCode
11. What are Indexes in MongoDB?

Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement.

#100DaysOfCode
12. How many indexes does MongoDB create by default for a new collection?

By default, MongoDB created the _id collection for every collection.

#100DaysOfCode
13. Mention the command to list all the indexes on a particular collection.

db.collection.getIndexes()

#100DaysOfCode
14. Why are MongoDB data files large in size?

MongoDB preallocates data files to reserve space and avoid file system fragmentation when you set up the server.

#100DaysOfCode
You can follow @_born_may.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.