SQl vs NoSql, Mongoose, CRUD operation, JWT token
Published: 2021-12-24 04:08:39

SQL vs NoSql database

First of all, you need to know, what is database?
A database is organized collection of information or data. It used for storing, maintaining and accessing data. Usually, it controlled by database management system (DBMS). There are two different kind of database. They are sql and noSql database. SQL is relational database on the other hand noSql is non-relational database.

There are many database available based on sql and non sql.
Sql database: MySql, PostgresQL, Oracle, Sqlite etc.
NoSql database: MongoDB, Redis, CouchDB, Cassandra, cosmosDB etc.


SQL database:
SQL is a relational model database. It use query language for define and manipulation data. In relational database the data organize as a set of tables with column and rows. Each column in table holds a certain kind of data. SQL database enable support for diverse workload. It reduce data storage footprint.

NoSql database:

NoSql database is non relational database. It store data in document format. It is similar to json objects. Each document contains fields and values. The values can be strings, numbers, booleans, arrays and objects. It is scalable and highly available. A limited database functionality enables high performance amongst many NoSql database. Mainly noSql database used for large amount of data with predictable query patterns. Because of it scale data horizontally, they can handle increased traffic simply by adding more server to database. Typically most nosql database have very flexible schemas. It allow us easily make changes in out database.



Mongoose

Mongoose is node.js based object data modeling library. It used for mongoDb. It is an object data model (odm) library. It manages relation between data, provides schema validation. Mongooes offers a variety of hooks, model validation and some features which make mongoDB work easier.


CRUD operation
The crud stands for create, read, update and delete. CRUD is data oriented and the standard use of http action verbs (POST, GET, PUT, DELETE)

Create operation: It performs the insert statement to create a new record.
Read operation: It reads record based on the input parameter.
Update operation: It update the record based on the input parameter.
Delete operation:  It deletes a row in the table. It is also based on the input parameter.


CRUD Operation
HTTP Method
Create
POST
Read
GET
Update
PATCH / PUT
Delete
DELETE



JWT token:

Jwt stands for json web token. It makes authorization an information exchange more secure. JWT consist three parts which is separated by dot. Three parts are header, payload and signature. 
In header jwt is mostly used to describe the cryptographic operations. It also contain data about the media. This information is present as a json object. This json object encoded to BASE64URL.2
The payload is second part of jwt where all the user data is actually added.This information is present as json object then this json object is encoded to BASE64URL.
Signature is the third part of jwt token. It used to verify the authenticity of token. 

Jwt token structure:
HASHINGALGO(base64UrlEncode(header) + “.” + base64UrlEncode(payload), secret)