Mongodb Interview Questions

What Are Nosql Databases? What Are The Different Types Of Nosql Databases?
A NoSQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases (like SQL, Oracle, etc.).

Types of NoSQL databases:

Document Oriented
Key Value
Graph
Column Oriented

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.

Which Are The Most Important Features Of Mongodb?
Flexible data model in form of documents
Agile and highly scalable database
Faster than traditional databases
Expressive query language

What Is A Namespace In Mongodb?
A Namespace is the concatenation of the database name and collection name. For e.g. school.students with school as the database and students as the collection.

Which All Languages Can Be Used With Mongodb?
Currently, MonggoDB 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. There are some other community supported drivers too but the above mentioned ones are officially provided by MongoDB.

Compare Sql Databases And Mongodb At A High Level.?
SQL databases store data in form of tables, rows, columns and records. This data is stored in a pre-defined data model which is not very much flexible for today’s real-world highly growing applications. MongoDB in contrast uses a flexible structure which can be easily modified and extended.

How Is Mongodb Better Than Other Sql Databases?
MongoDB allows a highly flexible and scalable document structure. For e.g. one data document in MongoDB can have five columns and the other one in the same collection can have ten columns. Also, MongoDB database are faster as compared to SQL databases due to efficient indexing and storage techniques.

Compare Mongodb And Couchdb At High Level.?
Although both of these databases are document oriented, MongoDB is a better choice for applications which need dynamic queries and good performance on a very big database. On the other side, CouchDB is better used for applications with occasionally changing queries and pre-defined queries.

Does Mongodb Support Foreign Key Constraints?
No. MongoDB does not support such relationships.

Does Mongodb Support Acid Transaction Management And Locking Functionalities?
No. MongoDB does not support default multi-document ACID transactions. However, MongoDB provides atomic operation on a single document.

How Can You Achieve Primary Key – Foreign Key Relationships In Mongodb?
By default MongoDB does not support such primary key – foreign key relationships. However, we can achieve this concept by embedding one document inside another. Foe e.g. an address document can be embedded inside customer document.

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.

Does Mongodb Pushes 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.

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 byte process id
3 byte counter

Mongodb Uses Bson To Represent Document Structures. True Or False?
True

If You Remove A Document From Database, Does Mongodb Remove It From Disk?
Yes. Removing a document from database removes it from disk too.

Mention The Command To Insert A Document In A Database Called School And Collection Called Persons.?
use school;
db.persons.insert( { name: “kadhir”, dept: “CSE” } )

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. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect.

How Many Indexes Does Mongodb Create By Default For A New Collection?
By default, MongoDB created the _id collection for every collection.

Can You Create An Index On An Array Field In Mongodb? If Yes, What Happens In This Case?
Yes. An array field can be indexed in MongoDB. In this case, MongoDB would index each value of the array.

Leave a Reply