BACKEND CONCEPTS
Published: 2021-12-23 17:09:09

	

## CRUD Operations
	

> What are CRUD operations?

Any organizations that tracks data (like accounts, payment information, or other records) need systems that provide persistent storage, which is usually organized into a database. A relational database consists of data organized by rows and columns. They can be connected to other tables using primary and foreign keys.
CRUD (create, read, update, delete) is an acronym that refers to the four functions we use to implement persistent storage applications and relational database applications, including the Oracle Database, Microsoft SQL Server, and MySQL.
	

> Why is CRUD so important?

CRUD is constantly used for anything related to database and database design. Software developers can’t get anything done without CRUD operations. Website development, for example, uses REST (Representational State Transfer), which is a superset of CRUD used for HTTP resources.
On the other end, CRUD is just as important for end-users. Without it, things like registering for websites, creating blogs, or bookmarks would be impossible. Most applications we use let us add or create new entries, search for existing ones, make changes to them or delete them.

**CRUD offers many benefits including:**

•	It facilitates security control by satisfying the various access requirements
•	It simplifies and facilitates application design making it more scalable
•	It has better performance compared to ad-hoc SQL statements

•	CREATE : Create allows you to add new rows to your table. You can do that using the command, INSERT INTO. The command starts with the INSERT INTO keyword, followed by the table name, column names, and the values to be inserted.

•	READ : The read function is similar to a search function, as it allows you to retrieve specific records and read their values. Read refers to SELECT 

•	UPDATE : Update is how we change an existing record in the table. We can use this to modify existing records that exist in the database. When performing UPDATE, you need to define the target table and columns to be updated. You also need the associated values and sometimes the rows. 

•	DELETE : Delete is used to remove a record from the table. SQL and has a built-in delete function for deleting one or more records from the database at a time. Some relational database applications may permit a hard delete (permanent delete) or soft delete (update row status).


	

## JWT

	

> What are JSON Web Tokens?

Most web apps use security measures to make sure user data stays private. Authentication is a key part of security and JSON Web Tokens (JWT) are a great way to implement authentication.
JWT is a standard that defines a compact and self-contained way to securely transmit information between a client and a server as a JSON object. The compact size makes the tokens easy to transfer through an URL, POST parameter, or inside an HTTP header. Also, since they are self-contained they include all the necessary information about a user so the database does not need to be queried more than once.
The information in a JWT can be trusted because it is digitally signed using a secret or public/private key pair.
	

> Authentication

JWT are mainly used for authentication. After a user logs in to an application, the application will create a JWT and send it back to the user. Subsequent requests by the user will include the JWT. The token tells the server what routes, services, and resources the user is allowed to access. JWT can be easily used across multiple domains so they are often used for Single Sign On.


	

## Express
	

> What is Express.js?

"Express is a fast, unopinionated minimalist web framework for Node.js" - official web site: Expressjs.com
Express.js is a web application framework for Node.js. It provides various features that make web application development fast and easy which otherwise takes more time using only Node.js.
Express.js is based on the Node.js middleware module called connect which in turn uses http module. So, any middleware which is based on connect will also work with Express.js.
	

> Advantages of Express.js

1.	Makes Node.js web application development fast and easy.
2.	Easy to configure and customize.
3.	Allows you to define routes of your application based on HTTP methods and URLs.
4.	Includes various middleware modules which you can use to perform additional tasks on request and response.
5.	Easy to integrate with different template engines like Jade, Vash, EJS etc.
6.	Allows you to define an error handling middleware.
7.	Easy to serve static files and resources of your application.
8.	Allows you to create REST API server.
9.	Easy to connect with databases such as MongoDB, Redis, MySQL