Mongo DB Notes - by Prakash
Mongo DB Notes - by Prakash
MONGODB
COMPLETE GUIDE
Overview
Introduction:
Key Features:
Flexible Querying: Supports rich query expressions, including nested objects and
arrays.
Document-Oriented:
Schema-less:
Scalability:
High Performance:
Flexible Querying:
MongoDB provides a powerful query language and rich querying capabilities for
retrieving and manipulating data.
Queries can target specific fields within documents, filter documents based on
complex conditions, and perform aggregations.
Support for nested objects, arrays, and a wide range of query operators allows
for expressive and flexible querying of data.
Basic Commands:
Command Description
Example Usage:
use myDatabase
db.users.find()
db.users.createIndex({ name: 1 })
MongoDB is a powerful database solution suitable for various types of applications, offering
flexibility, scalability, and performance advantages over traditional relational databases. Its
ease of use and extensive features make it a preferred choice for many developers and
organizations.
Replication:
MongoDB supports replication for ensuring high availability and data redundancy.
A replica set consists of multiple MongoDB instances, where one acts as the primary and others
as secondary replicas.
Automatic failover occurs if the primary replica goes down, ensuring continuous availability of
data.
Sharding:
Indexes:
MongoDB supports various types of indexes, including single field, compound, multi-key, and
geospatial indexes.
Indexes improve query performance by allowing MongoDB to efficiently locate and retrieve
data.
Careful index selection and usage are crucial for optimizing query performance and minimizing
resource usage.
Aggregation Framework:
Security:
MongoDB offers robust security features to protect data and ensure compliance with privacy
regulations.
Authentication mechanisms include username/password, LDAP, Kerberos, and X.509
certificates.
Role-based access control (RBAC) allows administrators to define fine-grained access
permissions for users and applications.
Transactions:
GridFS:
MongoDB's GridFS is a specification for storing and retrieving large files, such as images, videos,
and documents.
Files are divided into smaller chunks (default 255KB) and stored as separate documents.
Enables efficient storage and retrieval of large files without exceeding MongoDB's document
size limit.
Geospatial Queries:
Change Streams:
Change Streams enable real-time data change notification by watching changes to collections or
databases.
Applications can subscribe to change streams and receive notifications for inserts, updates,
deletes, and other operations.
Facilitates building reactive, event-driven architectures and real-time data processing pipelines.
MongoDB Atlas:
MongoDB Atlas is a fully managed cloud database service provided by MongoDB, Inc.
Offers automated provisioning, scaling, backup, and monitoring of MongoDB clusters in the
cloud.
Supports various cloud providers, including AWS, Azure, and Google Cloud Platform (GCP), and
provides built-in security and compliance features.
MongoDB has a vibrant community with extensive documentation, tutorials, and forums for
support and collaboration.
Rich ecosystem of tools, libraries, and integrations for various programming languages,
frameworks, and use cases.
Regular updates and releases introduce new features, enhancements, and optimizations to the
MongoDB platform.
These additional notes provide further insights into MongoDB's advanced features, capabilities, and
ecosystem, showcasing its versatility and suitability for a wide range of applications and use cases.