2018-10-06 THUDM team Eunbi Choi
SQL vs NoSQL
-
High-level differences
SQL NoSQL Relational database Non-relational database Table baesd Document based, key-value pairs, graph databases or wide-column stores Scale vertically - Increase the load on a single server. Scale horizontally - Scale across multiple hardwares. Pre-defined schema Dynamic schema Structured and unchanging data Unstructured and chainging data Language : SQL Language : UnQL (syntax varies from database to database) Examples : MySql, Oracle, Sqlite, Postgres, MS-SQL Examples : MongoDB, BigTable, Redis, Cassandra, CouchDB, Hbase ACID properties (Atomicity, Consistency, Isolation, Durability) Brewer's CAP theorem (Consistency, Availability and Partition tolerance) Mature Young Compelx queries Simple low level queries -
Advantage
SQL NoSQL Reliable data protection Fast and high performance Privilege and password security system Scalability Atomic transactions support Larege volume data Execellent support with developed community Fit for hierarchical data storage -
When to use
SQL NoSQL Need to ensure ACID compliancy - For high transactional based applications. Rapid development - Fit for agile development. Don't need to prepare data ahead of time.
MongoDB vs CouchDB
Redis
Redis is simple key-value in memory database with some data structures, therefore it can look up keys and return values very quickly.
According to the below article, Redis only needs 16MB to store one million key-value pairs. Expanding to 300 million keys, the total is just under 5GB.
Redis at Instagram (now switched to Cassandra from Redis): https://instagram-engineering.com/storing-hundreds-of-millions-of-simple-key-value-pairs-in-redis-1091ae80f74c
Data to store
-
room manager's data : id & password
-
room info : room id, manager id, creation date-> memory -
blacklist : user id-> memory -
...
The project's situation
-
There is only one data (room manager's data) to store yet.
-
Simple / small amount / changing data
-
Inexpensive hardware
-
Adopting agile methodology / Rapid development
-
Famililar with SQL and Redis, unfamiliar with NoSQL
Decision: undecided
Deciding between MongoDB and Redis.