• +91 9723535972
  • info@interviewmaterial.com

MongoDB Interview Questions and Answers

MongoDB Interview Questions and Answers

Question - 81 : - What are the restrictions of the MongoDB 32-bit versions?

Answer - 81 : -

When we run a 32-bit version of MongoDB, the total storage size of the server, containing indexes and data, is 2GB. Due to this reason, we will not deploy MongoDB to the production on the 32-bit machines. If we deploy a 64-bit version of MongoDB, there is no virtual restriction to the storage size. For the creation deployments, we strongly recommend 64-bit operating systems and builds.

Question - 82 : - When should we normalize the data in MongoDB?

Answer - 82 : -

It relies on our objectives. Normalization provides an updated effective data representation. Denormalisation makes data reading effective. Generally, we utilize embedded data models when:

  • When we have “contains” relationships between the entities.
  • When we have one-to-many relationships between the entities. In the relationships, “many”  or the child documents display in the context of the parent documents.
Generally, we use normalized data models:

  • When embedding results in duplication of the data yet they will not give enough read performance advantages to prevail the duplication implications.
  • For representing more difficult many-to-many relationships.
  • For modeling the big hierarchical data sets.

Question - 83 : - How do we perform sorting and Explain Project in MongoDB?

Answer - 83 : -

For finding any data in MongoDB, we use the find() method. The discovery () method returns the collection’s documents over which we invoked this method. We can use the “Where” clause in the MongoDB query in order to restrict the output by using MongoDB projection. Anytime we execute the find() method, MongoDB returns all the documents associated with a particular collection. 

db..find({ }, {:})

Question - 84 : - How can MongoDB simulate subquery or join?

Answer - 84 : -

We have to find the best method for structuring the data in MongoDB for simulating what would be the simple subquery or join in SQL. For example, we have users and posts, with the users in one collection and posts in another collection. We have to find all the posts by the users whose city is “Hyderabad”.

Question - 85 : - Define oplog(operational log)?

Answer - 85 : -

An operational log (oplog) is a special kind of limited collection that stores a rolling record of all the operations which change the data we store in our databases. Primarily, it applies all the database operations over the primary and, after that, records these operations on the oplog of the primary. After that, the secondary members replicate and apply the operations in the asynchronous process.

Question - 86 : - How do we create a database in MongoDB?

Answer - 86 : -

When I want to create a database in MongoDB, I faced the following error:

 :~$mongo

MongoDB shell version:1.65

Connecting to: test

Error: Could not connect to the server

Exception: connect failed
The solution to the above error:

  • cd/var1/lib1/MongoDB
  • We remove the mongod. lock from the folder
  • Sudo start MongoDB
  • Mongo

Question - 87 : - How do we delete everything from the MongoDB database?

Answer - 87 : -

By using the following code, we can delete everything from the MongoDB database:

use [database];
db.dropDatabase();
Ruby code should be pretty similiar.
Also, from the command line:
mongo [Database] -eval "db.dropDatabase();"
use
[databaseName]
db.Drop+databasename();
drop colllection
use databaseName
db.collectionName.drop();

Question - 88 : - Which command do we use for creating the backup of the database?

Answer - 88 : -

We use the mongodump command for creating the database backup.

Question - 89 : - Which command do we use for restoring the backup?

Answer - 89 : -

We use mongorestore for restoring the backup.

Question - 90 : - Explain the importance of the dot notation?

Answer - 90 : -

In MongoDB, we use dot notation for accessing the array elements and the fields of an embedded document.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners