TUTORIAL VIDEO


INTERVIEW QUESTIONS

MongoDB is a NoSQL, document-oriented database designed to store unstructured data. Unlike traditional relational databases, it uses collections and documents instead of tables and rows, making it highly scalable and flexible for handling big data applications.

A document in MongoDB is a JSON-like structure composed of key-value pairs. It is the basic unit of data in MongoDB and corresponds to a single record in a collection. Documents can have nested structures and dynamic schemas.

Collections in MongoDB are analogous to tables in relational databases. They are groups of documents with similar structures but no predefined schema, allowing for flexible and dynamic data storage.

Indexing in MongoDB improves the efficiency of search queries by creating special data structures to store a subset of fields from the documents. MongoDB supports various types of indexes, such as single-field, compound, multikey, and text indexes.

Replication in MongoDB is the process of synchronizing data across multiple servers to ensure high availability and redundancy. It is achieved using replica sets, which consist of a primary node and multiple secondary nodes that maintain copies of the data.

A sharded cluster in MongoDB is a distributed database system used to handle large datasets and high throughput. Sharding partitions data across multiple servers (shards) based on a shard key, enabling horizontal scaling and efficient query performance.

The Aggregation Framework in MongoDB is used to perform data processing and transformation operations. It provides a pipeline-based approach where multiple stages, like filtering, grouping, and projecting, can be chained to produce aggregated results.

MongoDB supports various data types, including:
  • String
  • Integer
  • Boolean
  • Array
  • Object
  • Null
  • Date
  • Binary Data

Backing up MongoDB data is typically done using the `mongodump` utility, which creates binary export files of the data. To restore the backup, use the `mongorestore` utility to import the files back into the MongoDB instance.

GridFS is a specification in MongoDB for storing and retrieving large files, such as images, videos, and audio, that exceed the BSON document size limit of 16MB. It splits files into smaller chunks and stores them in two collections: `fs.files` and `fs.chunks`.

QUIZ

1. What is MongoDB?

A NoSQL database
A relational database
A programming language

2. Which data format does MongoDB use to store documents?

BSON
JSON only
XML

3. Which command is used to display all documents in a MongoDB collection?

db.collection.find()
db.collection.show()
db.collection.fetch()

4. What does sharding in MongoDB help achieve?

Vertical scaling
Horizontal scaling
Data encryption

5. Which of the following is a valid MongoDB query operator?

=
$gte
LIKE