Prev Next

MongoDB / MongoDB Interview questions

Could not find what you were looking for? send us the question and we would be happy to answer your question.

What is MongoDB?

MongoDB is a document based no-sql database which provides high performance, high availability and easy scalability.

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

What is NoSQL database?

A NoSQL database provides a mechanism for storing and retrieval of data that is modeled in format other than the tabular relations used in relational databases such as MySQL, Oracle etc.

Types of NoSQL Database.

Types of NoSQL database are,

  • Document based,
  • Key Value,
  • Graph,
  • and Column Oriented.
List some of the important features of mongoDB.
  • Document oriented,
  • High performance,
  • High availability,
  • Easy scalability,
  • and rich query language.
Give few examples of NoSQL database.

MongoDB, Cassandra, CouchDB, Hypertable, Redis, Riak, Neo4j, HBASE, Couchbase, MemcacheDB, RevenDB and Voldemort are few examples of NoSQL database.

What are the core components of MongoDB package?

The core components in the MongoDB package are:

  • mongod, the core database process.
  • mongos the controller and query router for sharded clusters.
  • and mongo the interactive MongoDB Shell.
What is Namespace in MongoDB?

MongoDB stores BSON (Binary Interchange and Structure Object Notation) objects in the collection. The combination of the collection name and database name is called a namespace.

Difference between SQL and No-SQL terminologies.

SQL Terms/Concepts.MongoDB Terms/Concepts.
database.database.
table.collection.
row. document or BSON document.
column. field.
index. index.
table joins. $lookup, embedded documents.
primary key. primary key.
Specify any unique column or column combination as primary key.In MongoDB, the primary key is automatically set to the _id field.
aggregation (for example, group by).aggregation pipeline.

What is sharding in MongoDB?

Sharding is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.

MongoDB supports horizontal scaling through sharding.

Does MongoDB support primary-key, foreign-key relationship?

No. MongoDB doesn't support primary key-foreign key relationship.

MongoDB has _id key field for every document that uniquely identifies the particular document.

How do I achieve primary key - foreign key relationships in MongoDB?

The primary key-foreign key relationship can be achieved by embedding one document inside the another. As an example, a department document can have its employee document(s) embedded.

How replication works in MongoDB?

The process of synchronizing data across different servers is called replication. Replication gives redundancy and growing data availability with more copies of data on different database servers. It ensures high availablity by protecting the database from the loss of a single server.

Why is MongoDB not recommended for a 32-bit system?

32-bit MongoDB processes are limited to about 2 gb of data since MongoDB storage engine uses memory-mapped files for performance.

Does MongoDB support ACID transaction management and locking functionalities?

No. MongoDB does not support multi-document ACID transactions. However, MongoDB supports atomic operation on a single document.

Define replica set in mongoDB.

It is a group of mongo instances that maintain same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments.

Syntax used to create collection in mongodb.

db.createCollection(name,options) is used to create collection in mongodb.

What is journaling in mongoDB?

Journaling is used to safe the backups in mongodb.

Define primary replica sets in mongoDB.

The primary replica set accepts all the write operations from clients.

What is the use of profiler in mongoDB?

Profiler is used to measure the performance characteristics of every operation against the database.

Define secondary replica sets in mongoDB.

The secondary data sets replicate the primary's oplog and apply the operations to its data sets such that the secondaries' data sets reflect the primary data set.

Define vertical and horizontal scaling.

Vertical scaling adds more CPU and storage resources to increase capacity.

Horizontal scaling divides the data set and distributes the data over multiple servers, or shards.

How does the MongoDB pushes the writes to disk?

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

What is the structure of ObjectID in MongoDB?

ObjectID is a 12-byte BSON type. It is composed of,

  • 4 bytes value representing seconds,
  • 3 byte machine identifier,
  • 2 byte process id,
  • 3 byte counter.
What is the role of GridFS in mongodb?

GridFS is used for storing and retrieving the large/binary files like audio, Images, Video files.

Command used to create the backup of database in mongoDB.

Mongodump command is used to create the backup of database.

Command used to restore the backup in mongoDB.

Mongorestore command is used to restore the backup.

«
»
REDIS

Comments & Discussions