Code and notes in this repo follows this tutorial on udemy. However, major modification are made by me. The notes in this README file is also composed by me.
- Node.js
- Express.js
- MySQL
- MongoDB
- GraphQL
- REST stands for REpresentational State Transfer.
- Representation is of a resource(data).
- Transfer takes place from server to an application state.
- REST is stateless i.e. state is not managed by server.
- Resources are key business decision. eg. payments, orders, products etc.
- Resource entity is always declared in plural.
- An entity is not a single object.
http://domain.com/api/product/1 // wrong
http://domain.com/api/products/1 // right- Entity can be composed of multiple data source.
- Application that uses REST standards.
- Utilise HTTP or similar protocol.
- Uses HATEOAS.
- HTTP stands for Hypertext Transfer Protocol.
- It is used to send and retrive data through references in request and response objects.
- 10X : Information messages
- 20X : Success messages
- 30X : Redirection messages
- 40X : Client error messages
- 50X : Server error messages
- GET : requesting data
- POST : creating data
- PATCH : updating data
- PUT : partially creating data
- DELETE : deleting data
HTTP.GETandHTTP.DELETEare idempotent i.e. always does and returns same thing.HTTP.POST,HTTP.PUTandHTTP.PATCHare non-idempotent.
- Query language for REST API.
- Complements REST but not replace it.
- Acts as a middle man between REST API response and Client.
- Authentication is to verify a user
- Authorisation is to verify access to a user.
- Authentication is done via API keys, OAuth tokens or JWT.
- OAuth stands for Open authentication.
- JWT stands for JSON web tokens.
- JWT have base 64 encoded data.
- JWT =
header.payload.signature.
- URI stands for Uniform Resource Identifier. eg.
http://domain.com/api/departments/1- Express is a Node.js web server.
- It can handle routes.
- Have HTTP utilities.
- Have middlewares.
- Following URI have a query paramter
id.
http://domain.com/api/products/:idFollowing URI have a query string argument orderBy.
http://domain/api/products?orderBy=price:ASV-
RDMS was invented by Edgar F. Codd of IBM.
-
RDMS have following features:
- Tables
- Rows
- Columns
- Relationships
- Datatypes
- Keys: Primary, Foreign.
-
Relationships can be of following types:
- One-to-One
- One-to-Many
- Many-to-Many
-
SQL stands for Structured Query Language.
-
SQL is used to manage RDMS databases like MySQL, MariaDB, PostgreSQL etc.
-
It has following features:
- Database manager.
- Table manager.
- Index manager.
- System manager.
- User manager.
MySQL server is by default hosted on port 3306. Login to mysql shell with
$ mysql -u root -pCREATE DATABASE my_db;USE my_db;
CREATE TABLE my_table (
id INT NOT NULL AUTO_INCREMENT,
column1 VARCHAR(50),
column2 DATETIME,
PRIMARY KEY(id)
);INSERT INTO my_table
(column1, column2) VALUES
("something", "1980-09-22");UPDATE my_table
SET column1 = "nothing"
WHERE id = 1;DELETE FROM my_table
WHERE id = 1;SELECT column1, column2 FROM my_table;SELECT a.column1, b.column1
FROM my_table AS a
INNER JOIN my_table2 AS b
ON a.id = b.id;- Strict scheme.
- Ever changing data requirements.
- Data marts and lakes -- how to update them?