Mongoose and DB Connection
Introduction To MongoDB​
MongoDB is a popular NoSQL database system that provides high scalability, flexibility, and performance for managing large amounts of unstructured and semi-structured data.
There are two types of database:
- NoSQL
- SQL
MongoDB belongs to the NoSQL category, which means that it utilizes a non-relational data model for storing and managing data, So we Will use MongoDB database.
MongoDB Data Structure​
MongoDB organizes data in a flexible and scalable manner. Here are the key components:
Key-Value
: MongoDB stores data in documents, which are JSON-like objects consisting of key-value pairs. Each value can be of different types, such as strings, numbers, arrays, or even nested documents.Document
: A document in MongoDB is a set of key-value pairs. It is equivalent to a record or row in a relational database.Collection
: A collection is a group of related documents. It is analogous to a table in a relational database. Collections do not enforce a strict schema, allowing for flexibility in the structure of the stored documents.
Real life DataBase uses​
- Retail and E-commerce
- Banking and Finance
- Telecommunications
- Transportation and Logistics
Installing of MongoDB​
To create a MongoDB Atlas account and set up your database, follow these steps:
- Visit the MongoDB website at https://www.mongodb.com/.
- Click on the
Download
button.
- Choose the option to sign in with Google.
- Read and accept the Privacy Policy and Terms of Service by checking the checkbox.
Click on the
Submit
button.You will be redirected to the MongoDB Atlas dashboard, where you will be greeted with a welcome message.
- Answer the following questions as you know and discussed in Lecture.
- On the next page, you will be prompted to deploy your database. Choose the
Free
option.
Select your preferred cloud provider (e.g., AWS).
Choose the region where you want to deploy your database (e.g., Mumbai).
- After Creating a cluster set id and password .
- Add new IP adress and delete old adress.
- Allow access from anywhere and confirm.
- Copy connection string and save for future use.
- Complete remaining steps as discussed in lecture.
Steps to install MongoDB Compass​
To install MongoDB Compass, you can follow these steps:
Search for
MongoDB Compass
in your preferred search engine.Open the downloads page for MongoDB Compass.
Complete the installation process as disscussed in lecture.
Follow the on-screen instructions to install MongoDB Compass on your system. The installation process may vary depending on your operating system.
After the installation is complete, you can launch MongoDB Compass from your applications or programs menu.