developers often consider MongoDB
to be the main choice when building a data-driven application. However, many alternatives may provide better solutions.
This repository was built with the intention of exploring various database options to connect to Node.js backend such as:
- MongoDB (Users management, Data Seeding, Schema Generation)
dockerDefaultPort: 27017
- Redis (Session management, Set up Items services and basket services)
dockerDefaultPort: 6379
- MySQL. (Orders management, check-out services and review database relational links)
dockerDefaultPort: 3306
CRUD operations was built by using JS classes and instances.
Databases installed by pulling docker image from hub
A schema-based solution to modeling application data in MongoDB. It includes built-in type casting, validation, query building... designed to work in an asynchronous
environment.
Mongoose belongs to "Object Document Mapper (ODM)" category of the tech stack, while Sequelize
can be primarily classified under "Object Relational Mapper (ORM)".
An important subset of NoSQL databases are key value stores. While key value stores are very limited, they're also very powerful and fast. Redis
basically stores the data in memory which makes it blazingly fast but also, the data might get lost, if you kill the Redis
process.
Redis is often used as a cache. It can also be used as a storage when the consistency requirements are not high.
A robust, performance-focused and full-featured Redis client for Node.js.
Unlike NodeRedis, ioRedis supports promises
It provides Redis session storage for Express.
Redis methods (commands) are referred to the comprehensive doc at: Redis Commands
When to use relational databases:
- When there are multiple different entities that are in some way, related.
- When the database needs to stay in a consistent state.
- When the database should also enforce this consistency no matter from which application it is accessed.
Example in this app: Basket ↔ Order ↔ OrderItems
Unlike Redis and MongoDB, relational databases like MySQL rely on static table structures so-called 'schemas' to be defined directly inside the database.
A promise-based ORM for Node.js and io.js. It supports PostgreSQL
, MySQL
, MariaDB
, SQLite
and MSSQL
A powerful tool helps create a visual representation of relationship between different tables. With MySQL Workbench, you can reverse-engineer a database using a MySQL create script or you can connect to a live MySQL server and import a single database or a number of databases.
- It is a
sequence of ordered operations
performed on the database. - SQL statements are used to execute tasks such as update data or get data from a database.
- The SQL statements of a transaction will either
Commit
orRollback
using a rollback statement. - The transaction comprises of two results, they are either
success
orfailure
.