Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
MongoDB Interview Questions and Answers

MongoDB Interview Questions and Answers

October 31st, 2018

In case you’re searching for MongoDB  Interview Questions and answers for Experienced or Freshers, you are at the correct place. There is parcel of chances from many presumed organizations on the planet. The MongoDB  advertise is relied upon to develop to more than $5 billion by 2020, from just $180 million, as per MongoDB  industry gauges. In this way, despite everything you have the chance to push forward in your vocation in MongoDB  Development. Gangboard offers Advanced MongoDB  Interview Questions and answers that assist you in splitting your MongoDB  interview and procure dream vocation as MongoDB  Developer.

Best MongoDB  Interview Questions and Answers

Do you believe that you have the right stuff to be a section in the advancement of future MongoDB , the GangBoard is here to control you to sustain your vocation. Various fortune 1000 organizations around the world are utilizing the innovation of MongoDB  to meet the necessities of their customers. MongoDB  is being utilized as a part of numerous businesses. To have a great development in MongoDB  work, our page furnishes you with nitty-gritty data as MongoDB  prospective employee meeting questions and answers. MongoDB  Interview Questions and answers are prepared by 10+ years experienced industry experts. MongoDB  Interview Questions and answers are very useful to the Fresher or Experienced person who is looking for the new challenging job from the reputed company. Our MongoDB  Questions and answers are very simple and have more examples for your better understanding.
By this MongoDB  Interview Questions and answers, many students are got placed in many reputed companies with high package salary. So utilize our MongoDB  Interview Questions and answers to grow in your career.

Q1) Compare MongoDB and Cassandra


  • data mode are document
  • database scalability is read only
  • query of the data is multi-index


  • data mode are big table like
  • database scalability is write only
  • query of the data is using key or scana

Q2) what make magodb best?

it is consider has nosql database  because documented oriented (do).

Q3) When do we use Namespace in MongoDB?

in  database hte namespace is used

Q4) when an index does not fit into RAM?

index is very huge then index will not fit to RAM.

Q5) If you remove an object attribute, is it deleted from the database?

yes when the object attribute is delete then the object will be drop

Q6) Define MongoDB.

it th DO database which use in high availability and it is dynamic schema loction

Q7) What are the key features of mongodb?

  • high perform
  • high availability
  • automatic scaling,

Q8) what is meant by CRUD?

create read update delete

Q9)What is sharing in MongoDB?

the process of storing the record in multiple Machine is know has sharing.

Q10) How can you see the connection used by Mongos?

Mongos use db_adminCommand (“connPoolStats”);

Q11) Explain what is a replica set?

A replica set is the group of magodb instance which is host in same data set

Q12) How replication works in MongoDB?

the process of synchronization across the multiple server os know has replication.

Q13) While creating Schema in MongoDB what are the points need to be taken in consideration?

below are the following point need to be take care while carating the schema the combine objects into one document if you use them together for most frequent use cases optimize your schema

Q14) What is the syntax to create a collection?

db.create Collection(name,options)

Q15) What is the syntax to drop a collection?

drop collection in MongoDB is db.collection.drop()

Q16) Mention what is Object ld composed of?

  • Timestamp
  • Client machine ID
  • Client process ID
  • byte incremented counter

Q17) Mention what is the command syntax for inserting a document?

syntax :
database.collection.insert (document).

Q18) What is the command syntax that tells you whether you are on the master server or not? And how many master does MongoDB allow?

  • Command syntax
  • isMaster()

Q19) Mention the command syntax that is used to view Mongo is using the link?


Q20) Mention what is the basic syntax to use index in MongoDB?

syntax :
>db.COLLECTION_NAME.ensureIndex ( {KEY:1} ).

Q21)Explain what is GridFS in MongoDB?

while  storing and retrieving large files such as images.

Q22) What are alternatives to MongoDB?

  • Cassandr
  • CouchDB
  • Redis
  • Riak

Q23) What kind of NoSQL database MongoDB is?

It is a document oriented database.

Q24) Which all languages can be used with MongoDB?


Q25) How is MongoDB better than other SQL databases?

it Permits  highly flexible and scalable document structure. does not support such relationships.

Q26) Does MongoDB need a lot of RAM?

it can run on small amount of data because it is dynamic space are allocated and re-allocated.

Q27) What is Mongo DB?

It is an open source database and prominent NOSQL database.

Q28)     What are all the advantage of MongoDB?

  • It is a Schema less.
  • Structure of a single object is clear.
  • No complex joins.
  • Easy of scale-out

Q29) How to create the database in Mongo DB?

Use Database name
Example: Use MYDB

Q30) How to show the entire database?

Show dbs

Q31) What are the datatypes Mongo DB supports?

String, Integer, Boolean, Double, Array, Timestamp, Date, Regular expression

Q32) How to insert document in Mongo DB collection?


Q33) How to display all the documents?


Q34) What is the purpose of pretty () method?

Pretty () method used to display in formatted way.

Q35) What is the use of limit ()?

It will used to limit the value display from the documents.
DB.DBNAME.find ().limit (number)

Q36) What are all the Aggregate function in Mongo DB?

Sum, Avg, Min, Max, Push, addToSet, first, last

Q37) What is replication and why we need?

It is the process of synchronizing data across multiple server. It provides redundancy and increases data availability with multiple copies of data on different database server.WHY: To keep data safe, High availability of data, disaster recovery, No downtime for maintenance.

Q38) What is the syntax of sort() method?


Q39) What is CRUD?

CRUD operations are Create, Read, Update, Delete.

Q40) What is the syntax to drop the collections?


Q41) What is embedded documents?

Embedded documents are received while they were small, given the relations between the related data has been written in one body.

Q42) Define application level encryption.

Application Level Encryption provides encryption or per-per-written from the field in the application layer.

Q43) The encryption storage?

MongoDB encryption encrypts data stored on any storage or processing by operating system may not be able to access protected data.

Q44) When everything is in no way sufficient data to get extended to multi-cut?

That stands in a few MongoDB collection. Therefore, the list is kept in a lump of dough of all substances, it is either in size. It is only when there is additional time slot, there will be no piece of information was a few choices, but the lump is more than 1, data is far from a lot of slices and can be extended up to 64 MB.

Q45) The judge in the MongoDB and Couchbase and CouchbaseDB?

When the common segment DB DB is Couchbase Couchbase Brunfelsia necessary in many ways, crossing points, all of which differ in the form of ecological duplications etc. As to the execution

Q46) Miâ on how we use MongoDB?

By sequencing of database, and the names of the pages linked from a specified collection is used.

Q47) If you remove an object attribute database wipes?

So deleted. It is better to be safe to remove the attribute.

Q48) How can we move into the old directory file moveChunk?

Since, however, the present and the old files are converted to the backup file is moved at the time of the acquisition moveChunk directory space.

Q49) Explain the situation with the index does not fit in RAM?

MongoDB learned from the experts? Enroll today

Q50) What MongoDB will provide consistency?

The writer makes use of MongoDB is he that readeth, and the bolts of it, after allowing to access one considers arbitrary or that any one that my readers may at the same time as the collection of a database. And it always brings access to private and hated by others.

Q51) Why did not MongoDB 32-bit system because he chose?

32 bit candidate for a non-Brunfelsia DB is contained, that means running 32 bit with the MongoDB server, information and indexes require 2 GB. 32-bit, so it is not the only way to enter my thoughts.

Q52) How does working on Journaling MongoDB?

There is nothing memory Journaling saved. The book on-disk files are really useful to have said that the route habitual. DbPath interior is designed in the Journal subdirectory MongoDB.

Q53) How can we separate cursors connection with the write injustice?

Snapshot () method is used to separate them from coming in with cursors writes. Here is a list of query and make sure everyone comes to be, and the manner of his mother tongue, there has been only to look at the article.

Q54) Define MongoDB.

It may be a document is to be oriented database of speech, with which the top of their minds to ease of scalability and easy to get high performance. The Scheme supports dynamic policy.

Q55) Explain the image set.

I have to put the example of which is the group made up of Brunfelsia same knowledge of the set. To kill, and I need to provide high availability redundancy is the image of, and in the production of all of the deployments.

Q56) What are the key features of mongodb?

3 and of the sea There are, however, latae sententiae, which are mongodb scaling: High performance and high availability.

Q57) The Crud?

Mongodb provides Crud are created, Read, Update, Delete.
To learn more information about the MongoDB Crud click here.

Q58) The sharding?

Sharding to store data on multiple machines.

Q59) What is the sum of the MongoDB?

What matters are aggregations process data records and return the results of counting.

Q60) To define the nominal distance mongodb?

And what is the name of the collection database.

Q61)Syntax is used to create a collection mongodb?

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

Q62) That is to drop the mongodb?

db.collection.drop () is a collection to drop the mongodb.

Q63) Explain Infection.

Infection by more synchronous processing of data servers.

Q64) What is the use of index mongodb?

You can read a thing often used to provide a guideline for the high performance of queries.

Q65) The government should be inserted here because it is used?

database.collection.insert (document) is used for inserting the document.

Q66) What is the use of GridFS mongodb?

GridFS as I hear, is used for storage and for the most retrieving files, images, video files.

Q67) Journaling used?

Journaling is the use of the back of the mongodb to be saved.

Q68) That the government used to bond?

db_adminCommand ( “connPoolStats”); See the connection is not used.

Q69)Define the image killing?

The first things to write replicas but embraced the culture.

Q70) Define secondary image killing.

Secondaries (page 565) Brand apply for the primary, and op oplog.

Q71) Select the MongoDB equivalent query for the below SQL query – INSERT INTO employee (eid, age, salary) VALUES (763357, 45, 56489.40);

employee.insert( { eid: 763357, age: 45, salary: 56489.40 } )

 Q72) Identify the invalid statement

employee.insertMany( { [ emp_id:1, ename:”AAA” ] } )

 Q73) An “inventory” collection has documents stored in MongoDB in the following format:

{_id:1,  status: “available”,items: [ { sku:”006548e8″, details: {……} }, { sku:”0067458e8″, details: {……}  }  ], stocklevel:35, seller: “aaa” }

 Which of the following commands can be used to find all the documents in the “inventory” collection having stocklevel from 20 to 50? [20 and 50 inclusive]

inventory.find( { $nor: [ { stocklevel: { $lt:20 } },{ stocklevel:{ $gt:50 } } ] } ), db. inventory.find ( { stocklevel : { $gte: 20, $lte: 50 } } )

 Q74) Given the following documents in the electronics collection:

{ _id: 1, item: “oven”, price: 14000,quantity: 5 }

{ _id: 2, item: “LCD”, price: 48000, quantity: 10 }

{ _id: 3, item: “refrigerator”, price: 25000, quantity: 4 }

{ _id: 4, item: “LCD”, price: 56000, quantity: 3 }

{ _id: 5, item: “LCD”, price: 20000, quantity: 9 }

  What is the result of the below operation?

 db.electronics.update( {item : “LCD”, quantity : { $gte : 5 } },  { $set : { HD : “full HD” }, $inc : { price : 8000 } } )

Updates only the first matching document

 Q75) What would be the result of running the below query? – employee_profiles.deleteOne(   {‘unit’: ‘ETA’})

Only the first matching document is deleted

 Q76) The aggregation query in MongoDB that will sort the collection with ename field ascending.

employee.aggregate( [ { $sort: {ename:1} } ] )

 Q77) The command that creates an index on the quantity field, descending

inventory.createIndex( { “stock.quantity”:-1 } )

Q78) What is MongoDB?

MongoDB is a document-based database which is highly scalable, and offers better performance. Built around JSON-like documents, document databases are both natural and flexible for developers to work with.

Q79) How it is different from RDBMS?

  • Simple Data Model: Faster and Easier for Developers
  • Distributed: Resilient and Globally Scalable
  • Flexible Schema: Dynamically Adapt to Change
  • Universal: JSON Documents are Everywhere
  • Powerful: Query Data Anyway You Need

Q80) How much easier are document to work with SQL Tables?


ID FirstName LastName Cell  
1 Ajay Nadargi 123456  
ID userid   Designation  
10 1   Tester      
11 1   Developer      
ID userid   name   version
20 1   Project1   1.0.1
21 1   Project2   2.2.3
ID userid   make   year
30 1   Shree   2018
31 1   Varad   2019



FirstName : “Ajay”,

LastName : “Nadargi”,

Cell : 123456,

Designation : [ “Tester”, “Developer” ],

Projects : [

{ name : “Project1” , version : 1.0.1 },

{ name : “Project2” , version : 2.2.3 }


Makers : [

{ make : “Shree” , year : 2018 },

{ make : “Varad” , version : 2019 }



Q81) Need to run MongoDB?

  • High availability through built-in replication and failover
  • Horizontal scalability with native sharding
  • End-to-end security
  • Native document validation and schema exploration with Compass
  • Management tooling for automation, monitoring, and backup
  • Fully elastic database as a service with built-in best practices

Q82) Which types of NoSQL Databases?

  • Document databases store data in documents similar to JSON (JavaScript Object Notation) objects.
  • Key-value databases are a simpler type of database where each item contains keys and values.
  • Wide-column stores store data in tables, rows, and dynamic columns.
  • Graph databases store data in nodes and edges.

 Q83) How to start mongodb server/ instance?

  • mongod
  • mongod –dbpath /var/lib/mongo
  • mongod –port 27018
  • mongod –dbpath C:\Aj\data\db
  • mongod –logpath C:\Aj\logs\mongodb.log
  • mongod –port 27018 –dbpath C:\Aj\data\db –logpath C:\Aj\logs\mongodb.log — smallfiles
  • mongo –host mongodb0.example.com:27017

Q84) What is Bulk Write Operations?

  • MongoDB provides clients the ability to perform write operations in bulk. Bulk write operations affect a single
  • The collection.bulkWrite() method provides the ability to perform bulk insert, update, and remove operations. MongoDB also supports bulk insert through the db.collection.insertMany().
  • Bulk write operations can be either ordered or unordered.

Q85) Explain MongoDB CRUD Operation?

In MongoDB CRUD nothing but

  • Create Operations
  • Read Operations
  • Update Operations
  • Delete Operations

Create Operations 

  • Create or insert operations add new documents to a If the collection does not currently exist, insert operations will create the collection.
  • MongoDB provides  the  following  methods  to  insert  documents  into a collection:
    • collection.insertOne()
    • collection.insertMany()

Read Operations 

  • Read operations retrieves documents from a collection; e. queries a collection for documents. MongoDB provides the following methods to read documents from a collection:
    • collection.find()

Update Operations 

  • Update operations modify existing documents in a MongoDB provides the following methods to update documents of a collection:
    • collection.updateOne()
    • collection.updateMany()
    • collection.replaceOne()

Delete Operations

  •  Delete operations remove documents from a collection. MongoDB provides the following methods to delete documents of a collection:
    • collection.deleteOne()
    • db.collection.deleteMany()

Q86) How to create a database and a collection?

If a database does not exist, MongoDB creates the database when you first store data for that database. If a collection does not exist, MongoDB creates the collection when you first store data for that collection.

As such, you can switch to a non-existent database (use <dbname>) and perform the following operation:

  • use myCompanyDB
  • db.employee.insertOne( { id: 1 } )
  • db.department.createIndex( { dept_id: 1 } )

Q87) How do write operations affect indexes?

Write operations may require updates to indexes: If a write operation modifies an indexed field, MongoDB updates all indexes that have the modified field as a key. Therefore, if your application is write-heavy, indexes might affect performance.

Q88) How find the size of an index?

The db.collection.stats() includes an indexSizes document which provides size information for each index on the collection.Depending on its size, an index may not fit into RAM. An index fits into RAM when your server has enough RAM available for both the index and the rest of the working set.

Q89) What kind of replication does MongoDB support?

MongoDB supports replica sets, which can have up to 50 nodes.

Q90) What is a replica set?

The group of instances which host similar data set is known as a replica set. Two nodes are present in a replica set, one is secondary and the other is primary, where data is replicated from primary and sent to the secondary node.

Q91) Is it normal for replica set members to use different amounts of disk space?

Yes. Factors including: different oplog sizes, different levels of storage fragmentation, and MongoDB’s data file pre-allocation can lead to some variation in storage utilization between nodes. Storage use disparities will be most pronounced when you add members at different times.

Q92) How does mongos use connections?

Each mongos instance maintains a pool of connections to the members of the sharded cluster. Client requests use these connections one at a time; i.e. requests are not multiplexed or pipelined.

When client requests complete, the mongos returns the connection to the pool. These pools do not shrink when the number of clients decreases. This can lead to an unused mongos with a large number of open connections. If the mongos is no longer in use, it is safe to restart the process to close existing connections.

To return aggregated statistics related to all of the outgoing connection pools used by the mongos, connect a mongo shell to the mongos with , and run the connPoolStats command: db.adminCommand(“connPoolStats”);

Q93) Is sharding appropriate for a new deployment?

Sometimes. However, if your data set fits on a single server, you should begin with an unsharded deployment as sharding while your data set is small provides little advantage .

 Q94) What does sharding mean in MongoDB?

Sharding is a process of storing data records among one or more machines applied by MongoDB to meet the demands of data growth. It forms a horizontal partition in the database and each partition is known as database shard or a shard.

Q95) What is a storage engine?

A storage engine is the part of a database that is responsible for managing how data is stored, both in memory and on disk. Many databases support multiple storage engines, where different engines perform better for specific workloads. For example, one storage engine might offer better performance for read-heavy workloads, and another might support a higher throughput for write operations.

Q96) How can I check the size of a collection?

To view the statistics for a collection, including the data the db.collection.stats() method from the mongo shell. The following issues db.collection.stats() for the orders collection: db.orders.stats(); size, use example

Q97) How do I calculate how much RAM I need for my application?

With WiredTiger, MongoDB utilizes both the WiredTiger internal cache and the filesystem cache. The default WiredTiger internal cache size is the larger of either:

50% of (RAM – 1 GB), or 256 MB.

For example, on a system with a total of 4GB of RAM the WiredTiger cache will use 1.5GB of RAM (0.5 * (4 GB – 1 GB) = 1.5 GB). Conversely, a system with a total of 1.25 GB of RAM will allocate 256 MB to the WiredTiger cache because that is more than half of the total RAM minus one gigabyte ( 0.5 * (1.25 GB – 1 GB) = 128 MB < 256 MB)

Q98) What is the role of profiler in MongoDB?

The role of a MongoDB profiler is to show the performance and analyze the characteristics of every operation of the database. By using the profiler, you will find all the queries which are slower than usual.

Q99) MongoDB database support foreign-key and primary-key relationship?

No, by default, MongoDB doesn’t support foreign key or a primary key relationship.

Q100) How does MongoDB offer consistency?

To provide consistency, MongoDB makes use of reader-writer locks to allow readers to simultaneously access any collection like a database but it always offers private access to single writers.

Q101) In MongoDB what is Objecld composed of?

ObjectId(<hexadecimal>) Returns a new ObjectId value.

The 12-byte ObjectId value consists of:

  • a 4-byte timestamp  value,  representing  the  ObjectId’s  creation,  measured  in seconds since the Unix epoch
  • a 5-byte random value
  • a 3-byte incrementing counter, initialized to a random value

Q102) In MongoDB, which command can be used to provide all information of a query plan?

The explain() command is used to provide information of all the query plans. The possible models are as follows:

  • ‘queryPlanner’,
  • ‘executionStats’,
  • ‘allPlansExecution’

Q103) What feature in MongoDB is used to do safe backups?

To save backups of the old files “Journaling” feature is used in MongoDB databases.

Q104) Mongo complex sorting?

Sort queries in MongoDB by multiple fields, e.g.,db.collection.find().sort({a:1,b:-1}).

Q105) Which utility used for backup and restore?

mongodump provides a the mongod instances, while mongorestore makes BSON dump files into JSON. it method possible for creating BSON dump files from to restore these  dumps. bsondump converts mongoimport provides a method for taking data in JSON, CSV, or TSV and importing it into a mongod instance. mongoexport provides a method to export data from a mongod instance into JSON, CSV, or TSV.

Q106) MongoDB is supported by

  1. PHP
  2. Python
  3. All the mentioned
  4. Perl

Ans: All the mentioned

Q107) Different MongoDB Backup Methods?

  • Back Up with Atlas
  • Back Up with MongoDB Cloud Manager or Ops Manager o Back Up by Copying Underlying Data Files
  • Back Up with mongodump

Q108) How to check the MongoDB Performance?

  • Locking Performance
  • Number of Connections
  • Database Profiling
  • Full Time Diagnostic Data Capture

Q109) What are the MongoDB Configuration and Maintenance?

Run-time Database Configuration 

  • Outlines common MongoDB configurations and examples of best-practice configurations for common use cases.

Upgrade to the Latest Revision of MongoDB 

  • Introduces the basic process for upgrading a MongoDB deployment between different minor release versions.

Manage mongod Processes 

  • Start, configure, and manage running mongod

Terminate Running Operations

  • Stop in progress MongoDB client operations using db.killOp() and maxTimeMS().

Rotate Log Files

  • Archive the current log files and start new ones.

Q110) Explain Mongo Security?

MongoDB provides various features, such as authentication, access control, encryption, to secure your MongoDB deployments.

Q111) How to create User in MongoDB?

use products

db.createUser( { user: “accountAdmin01”,

pwd: passwordPrompt(),  // Or “<cleartext password>”

customData: { employeeId: 12345 },

roles: [ { role: “clusterAdmin”, db: “admin” },

{ role: “readAnyDatabase”, db: “admin” }, “readWrite”] },

{ w: “majority” , wtimeout: 5000 } )

Q112) “Complete the following statement: _____________is a data structure (most commonly a B- tree) that stores the values for a specific column in a table”

  1. index
  2. stored procedure
  3. check
  4. table

Ans: index

Q113) “Which one of the SQL joins is represented by the following example:






FROM Sales.SalesOrderDetail SOD

JOIN Production.Product P

ON SOD.ProductID = P.ProductID

WHERE SOD.UnitPrice> 1000


  1. Inner Join
  2. Left Outer Join
  3. Right Outer Join
  4. None from the options

Ans: Inner Join

Q114) “State True of False:

Indexes are automatically created for Primary keys and Unique key constraints”

  • TRUE


Q115) “Complete the following statement: A ___________ is a query that is nested inside a SELECT, INSERT, UPDATE, or DELETE statement”

  1. subquery
  2. Inner Join
  3. Outer Join
  4. None from the options

Ans: subquery

Q116) “State True of False: Indexes help SQL Server retrieve the data quicker”

  1. TRUE
  2.  FALSE


Q117) The integrity constrain “not null” specifies

  1. Nulls will not be allowed in the column
  2. Null will be allowed in a column
  3. can contain one and only one null
  4. none of the options

Ans: Nulls will not be allowed in the column

Q118) “Complete the Following Statements: A candidate key not chosen to be the Primary Key in a relation is called ______.”

  1. Alternate Key
  2. Alternative Key
  3. Foreign Key
  4. Super Key

Ans: Alternate Key

Q119) What does the term “the degree” of a relationship indicate?

  1. It is the number of participating entities in a relationship
  2. It indicates whether a relationship is one to many or many to many

Ans: It is the number of participating entities in a relationship

Q120) What kind of integrity does a foreign key represent?

  1. Entity Integrity
  2. Referential Inegrity
  3. User-defined Integrity
  4.  Domain check Integrity

Ans: Referential Inegrity

Q121) “Consider the following code snippet SELECT PRODUCT_NO,DESCRIPTION,SUM(PRICE * QTY) ‘Total Worth’ FROM PRODUCT GROUP BY PRODUCT_NO;”

  1. It will give an Error , and will not execute
  2. It will give the output as desired
  3. It will generate a warning but will also generate the output as desired
  4. It will crash sqlserver

Ans: It will give an Error , and will not execute

Q122) “Complete the following statement: The primary – foreign key relations are used to ____________”

  1. cross-reference database tables
  2. to index the database
  3. clean-up the database
  4. None from the options

Ans: cross-reference database tables

Q123) How many columns/attributes a single primary key can have?

  1. One
  2. Many
  3. Just two
  4. Zero

Ans: Many

Q124) Which SQL statement is used to update data in a database?

  2. SAVE
  4. SAVE AS


Q125) Which SQL statement is used to extract data from a database?

  1. OPEN
  4. GET


Q126) Which of the following command provides you with a list of all the databases in MongoDB?

  1. show dbs
  2. show databases
  3. show all dbs
  4. None of the above.

Ans: show dbs

Q127) „$set‟ is used for ___________.

  1. Delete
  2. Insert
  3. Update

Ans: Update

Q128) MongoDB supports indexes just like any other relational database.

  1. True
  2. False

Ans: True

Q129) Which of the following command creates an index, where mobile_no is a field in the collection employees

  1. employees.SetIndex( { “mobile_no”: 1 } )
  2. employees.ensureIndex( { “mobile_no”: 1 } )
  3. SetIndex( { “mobile_no”: 1 } )

Ans: employees.ensureIndex( { “mobile_no”: 1 } )

Q130) Which of the following command is correct when you want to fetch documents form collection demo, where value of a field „interest‟ is null?

  1. demo.find( { “interest : null” } )
  2. demo.find( { “interest” : null } )
  3. demo.find().sort( { “interest” : null } )

Ans: demo.find( { “interest” : null } )

Q131) MongoDB documents are represented as _____.

  1. JSON
  2. XML


Q132) Which of the following is equivalent to this: select first_name,salary from employees where designation=”Manager”; Assume that there are three columns first_name,salary,date_of_join.

  1. employees.find({“designation:Manager”},{“date_of_join” : 1})
  2. employees.find({“designation:Manager”},{“date_of_join” : 0})
  3. employees.find({“designation”:”Manager”},{“date_of_join” : 0})

Ans: employees.find({“designation”:”Manager”},{“date_of_join” : 0})

Q133) Which one of the following answers is equivalent to this SQL command: Select * from employees where date_of_join=”16/10/2010? and designation=”Manager” order by salary desc;

  1. employees.find({“date_of_join : 16/10/2010″,”designation:Manager”}).sort({“salary:-1”})
  2. employees.find({“date_of_join” :”16/10/2010″,”designation”:”Manager”}).sort({“salary”:-1})
  3. employees.find().sort({“date_of_join” : “16/10/2010″,”designation”:”Manager”}).sort({“salary”:-1})

Ans: employees.find({“date_of_join” :”16/10/2010″,”designation”:”Manager”}).sort({“salary”:-1})

Q135) „mongoimport‟ command is used for ___________.

  1. Multiple command import
  2. Multiple command insertion
  3. Provides a route to import content from a JSON, CSV, or TSV export created by mongoexport

Ans: Provides a route to import content from a JSON, CSV, or TSV export created by mongoexport

Q136) MongoDB supports query joins between collections.

  1. False
  2. True

Ans: False

Q137) Which of the following is correct command to update?

  1. books.update( { item: “book”, qty: { $gt: 7 } }, { $set: { x: 5 }, $inc: { y: 8} } , { multi: true} )
  2. books.update( { item: “book”, qty: { $gt: 7 } }, { $set: { x: 5 }, $inc: { y: 8} } )
  3. db.books.find().update( { item: “book”, qty: { $gt: 7 } }, { $set: { x: 5 }, $inc: { y: 8} } )

Ans: books.update( { item: “book”, qty: { $gt: 7 } }, { $set: { x: 5 }, $inc: { y: 8} } )

Q138) What does the following command do? db.demo.find({“extra.community_name” : “Rock”,”extra.friends.valued_friends_id”:”Jhon”})

  1. Fetch documents from the collection “demo” which contain the value of “community_name” “Rock’ and “valued_friends_id” is “Jhon”
  2. Fetch documents from the collection “demo” which contain the value of “community_name” is “Rock” and “valued_friends_id” which is under the “friends” is “Jhon” and all the said is under “extra” of an JSON style object,

Ans: Fetch documents from the collection “demo” which contain the value of “community_name” is “Rock” and “valued_friends_id” which is under the “friends” is “Jhon” and all the said is under “extra” of an JSON style object

Q139) Which one of the following is equivalent to Select * from employees order by salary

  1. employees.find().sort({“salary”:1})
  2. employees.sort({“salary”:1})
  3. employees.find().sort({“salary:1”})

Ans: employees.find().sort({“salary”:1})

Q140) Which of the following command is correct when you want to fetch documents from collection where only employees whose salary is 7500 and date of join is either of the given dates would come?

  1. employees.find().sort({ “salary” : “7500” , $or : [ { “date_of_join” : “17/10/2009” }; { “date_of_join” : “27/4/2010” } ] } );
  2. employees.find({ “salary” : “7500” , ($or : [ { “date_of_join” : “17/10/2009”, “date_of_join” : “27/4/2010” } ] } ));
  3. employees.find({ “salary” : “7500” , $or : [ { “date_of_join” : “17/10/2009” }, {“date_of_join” : “23/12/2009” } ] } );

Ans: employees.find({ “salary” : “7500” , ($or : [ { “date_of_join” : “17/10/2009”, “date_of_join” : “27/4/2010” } ] } ));