数据库相关的基础概览:SQL&NoSQL、ACID、Sharding
SQL Database
SQL: Structured Query Language
- MySQL
- PostgreSQL
- SQL Database use Table Model for data storage and they use SQL as a query language.
- Great for transactions, complex queries and integrity.
- ACID compliant.
#TODO
NoSQL Database
NoSQL: Not Only Structured Query Language
- NoSQL Database encompassed a variety of data models.
- Redis: Key-value Model ( In-Memory Database)
- MongoDB: Document Model(文档型,通常使用JSON、BJSON的数据格式)
- ClickHouse: Column-Family Model
- Graph Model
- In order to achieve better performance and scalability, immediate data consistency may be sacrificed to some extent, and data updates may not take effect immediately on all nodes.
- The query methods of NoSQL database vary according to the data model.
ACID Properties
Atomicity
- Transactions are all or nothing. Consistency
- After a transaction, the database should be in a consistent state. Isolation
- Transaction should be independent. Durability
- Once transaction is committed the data is there to stay.
Scaling Database
Vertical Scaling
- Increasing CPU power
- Adding more RAM
- Adding more disk storage
- Upgrading network
Horizontal Scaling
- Database sharding [[01-Sharding]]
- Replication [[02-Replication]]
Database Performance
- Caching
- Indexing
- MySQL-InnoDB
- Query Optimization
- Explain Plan