Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Mon

Exp goD
Rea ress B

Nod ct
.js

e.js
STA
CK
Contents
What is a database
SQL vs NoSQL databases
02
Advantages & Disadvantages
of MongoD
When to choose MongoDB ? 03
Installation

Basic Queries
Aggregation Operation
Mongoose
04

What is MongoDB Atlas


Creating a basic CRUD app
with mongoos
05
Submission Link
What is a database?
Before we start MongoDB, we first have to understand what is database actually is.

Data is a collection of discrete units of information. It can be the names of users, their ages, interests, etc. We
need a place to store this data. A database is an organized collection of data to make it easily manageable,
accessible, and easy to update. In simple terms, a database is where data is stored.

More on databases:

https://en.wikipedia.org/wiki/Database

SQL vs. NoSQL databases


SQL or Structured Query Language is used to manage relational databases. A relational database is a
collection of information that is stored in the form of one or more tables. Relational databases are among the
most popular types of databases.

NoSQL databases do not use SQL, and there is no "table" in NoSQL databases. They are non-tabular
databases. Instead, data is stored in JSON-like documents.

Both databases have their unique features and use. We will focus on MongoDB now, which is a NoSQL
database.

Features of MongoDB :
Flexible Schema
Horizontal Scaling
Fast Querie
Easy and convenient for developers

More on horizontal scaling:

https://www.geeksforgeeks.org/horizontal-and-vertical-scaling-in-databases/

SQL and NoSQL complete comparison:

https://www.geeksforgeeks.org/difference-between-sql-and-nosql/

Advantages and disadvantages of MongoDB


Advantages

Flexible Document Schemas: MongoDB’s document model allows any data structure to be modeled and
manipulated easily
High performance: Because of the document model used in MongoDB, information can be embedded
inside a single document. This makes queries much faster and returns all the necessary information in a
single call to the database
Easy horizontal scale-out with sharding: Since MongoDB is a NoSQL database, horizontal scaling
becomes very easy and effective.

Disadvantage
Consistency of data: Mongo and other NoSQL databases are flexible and fast, but when it comes to data
consistency, NoSQL databases are not very consistent
No standard rules: There are no standard rules for the roles of NoSQL databases.

When to choose MongoDB


There are no set rules that need to be followed when choosing a database for your app. But choosing the
correct database can enhance development speed and process.

We chose MongoDB or other NoSQL databases when we needed to work with:


Unstructured or semi-structured dat
Dynamic schema of dat
Horizontal scalabilit
Require less level of data integrity

Installation (MongoDB Community Edition)


https://www.mongodb.com/docs/manual/installation/

OR

Use the online MongoDB terminal to learn basic queries

Terms in MongoDB

Learn the basic terminologies of MongoDB before getting started to understand everything better.

https://www.tutorialspoint.com/mongodb/mongodb_overview.htm
Basic Queries in MongoDB for CRUD Operations
Create operations

The basic syntax of create/use DATABASE statement is as follows : use DATABASE_NAME

Delete/Drop database

Basic syntax of dropDatabase() command is as follows : db.dropDatabase()

More Commands: https://www.youtube.com/watch?v=ofme2o29ngU&ab_channel=WebDevSimplified

Aggregation Operations
Aggregations operations process data records and return computed results. Aggregation operations group
values from multiple documents together, and can perform a variety of operations on the grouped data to
return a single result.

How to use aggregation in MongoDB :

https://www.tutorialspoint.com/mongodb/mongodb_aggregation.htm

Mongoose
What is mongoose?

In simple words, mongoose is a Node package that allows you to work with MongoDB from your NodeJS
application. Mongoose is a MongoDB object modeling tool designed to work in an asynchronous
environment.

Installing Mongoose

NPM : npm i mongoose

YARN : yarn add mongoose

What is MongoDB atlas?


MongoDB Atlas is a platform that allows you to deploy your database on the cloud. It makes the
development process very efficient.

You can create a free account on Atlas and get a free database hosted.

Official Documentation: https://www.mongodb.com/atlas/database

Tutorial: https://www.youtube.com/watch?v=KKyag6t98g8&ab_channel=TraversyMedia

Creating a basic CRUD app with mongoose

Follow this tutorial to create a crud app with Node

https://www.youtube.com/watch?v=5QEwqX5U_2M&ab_channel=codedamn

Submission Form

https://forms.gle/nVSq58Jowbbog6zw9

You might also like