Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is use of _id Field in MongoDB?

Answer»

What is use of _id Field in MongoDB?
In MongoDB we use _id field always as a first field in the documents THEREFORE each document stored in a COLLECTION REQUIRES a UNIQUE _id field which is acts as a primary KEY.

2.

Which command is used to insert document in MongoDB?

Answer»

Which COMMAND is USED to INSERT DOCUMENT in MONGODB?
Below is the command to insert a document in MongoDB:-
database.collection.insert(document)

3.

MongoDB Count() and Remove() function with example

Answer»

MongoDB COUNT() and Remove() function with example
Count() is used to get the count of documents in a COLLECTION as PER the query EXECUTED. And syntax is GIVEN below
db.Employee.count()

Remove() is used to remove documents from a collection. We can delete documents by a sepcific condition too. Below is the syntax:
db.Employee.remove({Employeeid:10})

4.

Write down a syntax to view a connection in MongoDB?

Answer» WRITE down a SYNTAX to VIEW a connection in MONGODB?
Below is the command to view the connection in MongoDB:-
db_adminCommand
5.

If we delete an object attribute is it delete from database in MongoDB?

Answer»

If we delete an object ATTRIBUTE is it delete from database in MONGODB?
Yes if we delete an object attribute this will delete from database. So it is better to eliminate the attribute and then SAVE object again.

6.

Do you know the idea of splitting in MongoDB?

Answer»

Do you know the idea of splitting in MongoDB?
Splitting in MongoDB is one of the PROCESS which KEEPS chunks from growing too large with the help of split command(). And whenever a chunks grows beyond the specified CHUNK SIZE MongoDB splits the chunks. And this is be done on the basis of shard key VALUES the chunk represents.

7.

Write down some of the common difference between MongoDB and MSSQL?

Answer» WRITE down some of the COMMON DIFFERENCE between MONGODB and MSSQL?
Below are the some of the common difference between MongoDB and MSSQL:-
8.

Why we use Replication in MongoDB and its benefits?

Answer»

Why we use Replication in MongoDB and its benefits?
In MongoDB replication is one of the process to synchronize DATA on multiple servers. With replication data is redundant and will have multiple copies of data on different database servers. And replication will protects data from loss as this will be available on multiple server. And replication will also helps to recover data from hardware failure and service interruptions. As we have multiple server with same data we will dedicate one as disaster recovery, reporting or for backup. And below is th facts why replication is used:-
(1)Replication help to keep our data safe.
(2)Replication helps in disaster recovery.
(3)Replication helps to data AVAILABILITY to 24*7
(4)Here we donot need a downtime for maintenance for EXAMPLE backup, index REBUILDS and compaction.
(5)Replication will also helps in Read scaling as we have extra copies of data
(6)Replica set is transparent to application

9.

What do you thing MongoDB need lot of RAM to execute MongoDB process?

Answer»

What do you thing MongoDB NEED lot of RAM to EXECUTE MongoDB process?
My answer is No, as MongoDB is smart enough to ALLOCATE memory and deallocate the memory. MongoDB can be run on small amount of RAM. MongoDB have features to use memory BASED on the requirements of other processes. And MongoDB can dynamically allocates and de-allocates RAM.

10.

Can you please define the drop() method for collection in MongoDB?

Answer»

Can you please define the drop() method for collection in MONGODB?
In MongoDB we USE db.collection.drop() to drop a collection from DATABASE. And syntax to drop() command is GIVEN below.

db.Collection_name.drop()

But it is always a good practice to CHECK the avaialble collection before droping them from database in MongoDB. And to check them we use below code or syntax.

(1)Use database_name
to enter in database where collection is exists

(2)show collections
After entering into database we will use above command to show the collections

And now we use below command to drop the collection from database.

db.Collection_name.drop()

11.

How to create a collection in MongoDB and example with parameter?

Answer»

How to create a collection in MongoDB and example with parameter?
In MongoDB we use db.createCollection(NAME, options) to create collection. And below is the SYNTAX to create collection in MongoDB with some parameter list.

db.createCollection(name, options)

In above command we have two parameter name and options. Here Name is name of collection which we create. And now second parameter Options which is DOCUMENT which is used to specify CONFIGURATION of collection.


In second parameter options we have list of below given options

12.

Use of GridFS in mongodb

Answer»

Use of GRIDFS in mongodb
We use GridFS for storing and retrieving the LARGE files like AUDIO, iamges and video files.

13.

What is Cursor in MogoDB and example

Answer»

What is Cursor in MogoDB and example
Cursor is a POINTER to the result SET of a query. A pointer to result set of a query. Clients can iterate through a cursor to RETRIEVE results. and below is the example to CREATE a Cursor in MongoDB:


var myCursorVar=db.users.find({"age":20});
while (myCursorVar.hasNext())
{
print(tojson(myCursorVar.next()));
}

14.

How to add MongoDB array using insert() with example

Answer»

How to ADD MongoDB array using insert() with example
Insert command in MongoDB is USED to insert multiple DOCUMENT into the collection. Below is code to user insert()
(1)First we will create a Javascript variable CALLED myEmployee which hold the array of documents
(2)Now in step 2 we add required documents with Field Name and values in that variable
(3)Use insert command to insert array of documents into the collection

var myEmployee=
[
{
"Employeeid" :1,
"EmployeeName" : "Adam"
},
{
"Employeeid" : 2,
"EmployeeName" : "Sutro"
},
{
"Employeeid" : 3,
"EmployeeName" : "Joe"
},
];

db.Employee.insert(myEmployee);


when we EXECUTE above code record will be insert

15.

What are the four Vs of Big Data?

Answer»

What are the four Vs of BIG Data?
Below are the four Vs of big data
(1)Volumne:- This will TALK about the amount of data.
(2)Variety:- This will talk about the various formats of data.
(3)Velocity:- This will talk about the increasing speed at which the data is growing
(4)VERACITY:- This will talk about the DEGREE of accuracy of data available.

16.

What type of Database is MongoDB

Answer»

What TYPE of DATABASE is MongoDB
MongoDB is DOCUMENT ORIENTED DBMS

17.

Why 32-bit System not suitable for MongoDB

Answer»

Why 32-bit System not suitable for MongoDB
There is very solid reason why MongoDB is not considered for 32-bit system. To run 32-bit MongoDB in server we require 2GB to use information and indexes in it. So it is not used 32-bit devices as this 32-bit system will not provide 2GB for OPERATION. MongoDB storage ENGINE uses memory-mapped files for PERFORMANCE which atleast NEED 2GB SPACE.

18.

Different languages supported by MongoDB

Answer»

Different languages supported by MongoDB
Below are the different 12 languages supported by MongoDB official driver support
(1)C
(2)C++
(3)c#
(4)Java
(5)Node.js
(6)Perl
(7)PHP
(8)PYTHON
(9)RUBY
(10)SCALA
(11)Go
(12)Erlang

19.

What feature of MongoDB is used for safe backups

Answer»

What FEATURE of MONGODB is used for SAFE backups
Name of feature of MongoDB which is used for safe backups is Journaling.

20.

Is MongoDB is RDBMS or not

Answer»

Is MONGODB is RDBMS or not
No MongoDB is not RDBMS