Skip to main content

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:

  1. NoSQL
  2. 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:

  1. 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.
  2. Document: A document in MongoDB is a set of key-value pairs. It is equivalent to a record or row in a relational database.
  3. 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​

  1. Retail and E-commerce
  2. Banking and Finance
  3. Telecommunications
  4. Transportation and Logistics

Installing of MongoDB​

To create a MongoDB Atlas account and set up your database, follow these steps:

  1. Visit the MongoDB website at https://www.mongodb.com/.
screenshot
  1. Click on the Download button.
screenshot
  1. Choose the option to sign in with Google.
screenshot
  1. Read and accept the Privacy Policy and Terms of Service by checking the checkbox.
screenshot
  1. Click on the Submit button.

  2. You will be redirected to the MongoDB Atlas dashboard, where you will be greeted with a welcome message.

screenshot
  1. Answer the following questions as you know and discussed in Lecture.
screenshot
  1. On the next page, you will be prompted to deploy your database. Choose the Free option.
screenshot
  1. Select your preferred cloud provider (e.g., AWS).

  2. Choose the region where you want to deploy your database (e.g., Mumbai).

screenshot
  1. After Creating a cluster set id and password .
screenshot
  1. Add new IP adress and delete old adress.
screenshot
  1. Allow access from anywhere and confirm.
screenshot
  1. Copy connection string and save for future use.
screenshot
  1. Complete remaining steps as discussed in lecture.

Steps to install MongoDB Compass​

To install MongoDB Compass, you can follow these steps:

  1. Search for MongoDB Compass in your preferred search engine.

    screenshot
  2. Open the downloads page for MongoDB Compass.

    screenshot
  3. Complete the installation process as disscussed in lecture.

    screenshot
  4. Follow the on-screen instructions to install MongoDB Compass on your system. The installation process may vary depending on your operating system.

  5. After the installation is complete, you can launch MongoDB Compass from your applications or programs menu.

    screenshot