MST Unit 5
MST Unit 5
Collection in Mongo DB. Deploying Applications: Web hosting & Domains, Deployment
Using Cloud Platforms.
Document-Oriented:
MongoDB stores data as documents, which are similar to JSON objects, consisting of key-
value pairs.
NoSQL:
As a NoSQL database, MongoDB does not rely on tables and fixed schemas like relational
databases.
Flexible Schema:
MongoDB provides flexibility in data storage, allowing for dynamic schemas where
documents within a collection can have different structures.
Scalability:
MongoDB supports horizontal scaling, allowing you to distribute data across multiple
servers for high availability and performance.
Features:
MongoDB offers features like indexing, aggregation pipelines (for data transformation),
and server-side JavaScript execution for enhanced data management.
Use Cases:
MongoDB is often used for applications requiring flexibility, scalability, and high
performance, including web applications, content management systems, and big data
analytics
Mongo DB Architecture
Security in MongoDB
Mongodb provides various security mechanisms to protect data from unauthorized access
and breaches
Authentication - Verifies user credentials
Authorization - Assigns role -based access controls (RBAC).
3. MongoDB Server
It serves as the central element and is in charge of maintaining, storing, and retrieving
data from the database through a number of interfaces.
MangoDB Feature
1. Document-Oriented:
MongoDB stores data in JSON-like documents, making it suitable for hierarchical and
complex data structures.
2. Schema-less:
MongoDB does not require a predefined schema, offering flexibility for data modeling and
evolving applications.
3. Indexing:
MongoDB supports various indexing options, allowing for efficient querying and faster data
retrieval.
4. Aggregation:
MongoDB's aggregation framework allows for powerful data processing and transformation
pipelines.
5. Replication:
MongoDB's horizontal scaling capabilities allow it to handle large volumes of data and high
traffic loads.
Database Creation: Databases are created when you insert data into them. You can create
or switch to a database using the following command:
use <database_name>
This command actually switches you to the new database if the given name does not exist
and if the given name exists, then it will switch you to the existing database. Now at this
stage, if you use the show command to see the database list where you will find that
your new database is not present in that database list because, in MongoDB, the database
is actually created when we start entering data in that database.
4. View Database: To see how many databases are present in your MongoDB server, write
the following statement in the mongo shell:
show dbs
Deploying web hosting and domains with MongoDB using cloud platforms
involves leveraging cloud services to manage your web application's infrastructure, including
the database and web server, while also handling domain registration and management. This
can be achieved by using cloud providers like AWS, Azure, Google Cloud, or even dedicated
MongoDB cloud solutions like MongoDB Atlas.
Cloud Providers:
AWS, Azure, and Google Cloud offer various services for web hosting, database
management (including MongoDB), and domain registration/management.
MongoDB Cloud Solutions:
MongoDB Atlas is a fully managed cloud database service specifically designed for
MongoDB.
2. Web Hosting and Application Deployment:
Web Hosting:
Choose a cloud service that provides web hosting, such as an App Service, Virtual
Machine, or a serverless function.
Application Deployment:
Deploy your web application's code to the web hosting service. This can involve using
deployment tools or manually uploading your application files.
3. MongoDB Database Setup:
Connection String:
Obtain the MongoDB connection string from your cloud provider or MongoDB Atlas.
Application Code:
Use the connection string in your web application's code to connect to the MongoDB
database.
6. Scaling and Performance:
Elastic Scaling: Leverage the cloud platform's elastic scaling capabilities to automatically
adjust resources based on demand.
Load Balancing: Use load balancers to distribute traffic across multiple web servers.
Caching: Implement caching strategies to improve page load times.
7. Security:
Firewall Rules: Configure firewall rules to restrict access to your MongoDB instances.
Authentication: Implement secure authentication mechanisms for your web application and
MongoDB.
Encryption: Utilize encryption for data at rest and in transit.