Frequently asked MongoDB interview questions and answers for freshers, 2-4 year experienced developers & DBA's to help you succeed in the job interview.
MongoDB is a document database which provides good performance and it is a leading NoSQL. It stores the document data in BSON structure.
- Cross Platform
- Provides High Performance
- Easy scalability
- No Complex Joins
- Schema less
- Available on AWS, Azure etc.
4) What is a Database?
A Database is a container of all the Collections. Every database will have a physical file associated in the file system.
5) What is a Collection?
The Collection is group of Documents in MongoDB. In RDBMS, this can be considered as a table which will have list records (documents in MongoDB).
6) What is a Document?
The Document is a set of key-value pairs. In RDBMS, each record in a table is equivalent to document in MongoDB. Documents will have a dynamic schema, meaning, documents in a collection no need to have a same structure/fields.
7) Compare MongoDB and RDBMS?
Below are MongoDB equivalent in RDBMS –
|Embedded Documents||Table Join|
8) What is “mongod”?
It is a host process for the database. When we start mongod, it means starting the MongoDB process and run it in the background.
9) What are the parameters for “mongod”?
Mongod Parameters are for following things -
- Storing the data in the given path. By default – “/data/db”.
- Port Number, By default – “27017”.
10) What is “mongo”?
It is the command shell used to connect to a specific instance of mongod. When we run the mongo command with no parameters, it will try to connect to, default port number – 27017 and localhost.
11) What is the MongoDB command to switch the databases?
To switch the database in MongoDB use – “use databasename” command.
12) What is NoSQL?
NoSQL provides data retrieval and data storage. No SQL used in Big Data, Web Apps etc. because of simple design and good performance.
13) What are the types of NoSQL?
Below are the types of NoSQL –
- Key-Value Store – It will have a has table with keys and values. (Eg : Amazon S3)
- Graph – It uses edge and nodes to represent the data. (Eg: Neo4J)
- Document Store – It stores data in the form of documents. (Eg: MongoDB)
- Column Based Store – Each Storage clock contains data from only one column. (Eg: Cassandra)
14) Why to use MongoDB?
Below are the reasons to go for MongoDB –
- Data are stored in JSON which mean it’s supported in cross platform.
- Rich Queries
- Fast updates
- Support in MongoDB
- Replication and High Availability
15) Where we can use MongoDB?
Below are the places where we can use MongoDB –
- Big Data
- Content Management Systems
- Mobile Apps
- Data Management
16) What is the meaning of Namespace in MongoDB?
A Namespace is a combination of Database Name and Collection Name.