MongoDB QnAs for Vivavoce

 

  1. What is MongoDB, and why is it called a NoSQL database?

    • MongoDB is a document-oriented NoSQL database that stores data in JSON-like documents. It is called NoSQL because it does not use traditional SQL (Structured Query Language) for querying data.
  2. What is a document in MongoDB?

    • A document in MongoDB is a JSON-like object that contains key-value pairs and is the basic unit of data storage.
  3. Explain the structure of a MongoDB document.

    • A MongoDB document consists of fields, which are key-value pairs, and it can have nested documents and arrays.
  4. What is a collection in MongoDB?

    • A collection in MongoDB is a group of MongoDB documents. It is similar to a table in a relational database.
  5. How do you insert a document into a MongoDB collection?

    • You can insert a document into a collection using the insertOne() or insertMany() method.
  6. Explain the concept of ObjectId in MongoDB.

    • ObjectId is a 12-byte identifier that is unique within a collection and is automatically generated for each document. It consists of a timestamp, machine ID, and more.
  7. What is indexing in MongoDB, and why is it important?

    • Indexing in MongoDB is the process of creating a data structure to improve the speed of data retrieval operations on a database. It is important for optimizing query performance.
  8. What is the primary key in MongoDB?

    • In MongoDB, the primary key is the _id field, which uniquely identifies each document in a collection.
  9. Explain the difference between a replica set and a sharded cluster in MongoDB.

    • A replica set is a group of MongoDB servers that maintain the same data for redundancy and high availability. A sharded cluster, on the other hand, is used for horizontal scaling and distributing data across multiple servers.
  10. What is the purpose of the MongoDB aggregation framework?

    • The aggregation framework in MongoDB is used for data transformation, filtering, and computation of data. It allows for complex data processing tasks.
  11. How do you perform a query in MongoDB to retrieve documents that match certain criteria?

    • You can use the find() method to perform queries in MongoDB. For example, db.collection.find({ field: value }).
  12. What is the $set operator used for in MongoDB?

    • The $set operator is used to update specific fields within a document without affecting other fields.
  13. Explain the difference between a NoSQL database like MongoDB and a traditional relational database.

    • NoSQL databases like MongoDB are schema-less, whereas relational databases have a fixed schema. NoSQL databases are suitable for unstructured data, while relational databases are ideal for structured data.
  14. What is sharding in MongoDB, and when should you consider using it?

    • Sharding is the process of distributing data across multiple servers to improve scalability and performance. It should be considered when a single server can't handle the data and traffic volume.
  15. How do you ensure data consistency in a replica set in MongoDB?

    • Data consistency is maintained in a replica set through automatic failover. When the primary node goes down, one of the secondary nodes is automatically elected as the new primary.
  16. What is the purpose of the mongod process in MongoDB?

    • The mongod process is the primary daemon process for MongoDB, responsible for managing the database server.
  17. What is the WiredTiger storage engine in MongoDB, and why is it widely used?

    • WiredTiger is the default storage engine in MongoDB, known for its high performance and data compression capabilities. It's widely used for improved efficiency.
  18. Explain the concept of "write concern" in MongoDB.

    • Write concern in MongoDB determines the acknowledgment level that a write operation must achieve to be considered successful. It can be set to "acknowledged," "journaled," or "majority," among other options.
  19. What is the purpose of the MongoDB Atlas service?

    • MongoDB Atlas is a cloud-based database service provided by MongoDB for managing and hosting MongoDB databases in the cloud.
  20. How do you back up and restore data in MongoDB?

    • You can back up data in MongoDB using tools like mongodump, and you can restore data using mongorestore. These tools work with binary BSON data.

Comments

Popular posts from this blog

9. Angular and MongoDBs

1. a. Angular Application Setup

2. Structural Directives - ngIf