Relational vs non-relational databases

Relational database (tables + link keys) Non-relational database
Stores and organizes data in tables. Not tabular relational database model.
SQL follows a strict schema. NoSQL deals with dynamic schema and is very flexible.
These tables are related to each other through the use of foreign keys, which are used to link data stored in different tables. Types of NoSQL databases:
  1. document=JSON
  2. key-value
  3. graph=nodes (real information) and edges (relationships)
  4. wide-column=dynamic columns. | | Pros: Great querying capabilities. You may perform complex queries with SQL. Because queries are executed directly inside the database. You can’t use Python, because first you need to load to memory large amount of data. | Pros: flexible schema, horizontal scaling, fault-tolerant. | | ACID (atomicity=success, consistency=schema, integrity=no effect to others, durability=no lost) | Good if you have a lot of data, you want law latency. | | Indexes: performance optimizer, improve the speed of data access | | | Normalization: reduces redundancy and ensures that data is stored in the most efficient way. | | | SQL queries tuning: analyzing the execution plans of slow queries and making adjustments to the query structure | | | Partitioning (creating new tables that divide table into smaller chunks). A partition is a logical database’s split into separate, independent portion.
  5. Range-based partitioning based on 12 months, based on years.
  6. Hash-based partitioning.

Sharding is a partitioning technique, dividing data across multiple databases or servers. | | | Replication

  1. Master-slave=ONLY MASTER receives updates
  2. peer-to-peer=no special master, all are slaves
  3. multi-master=MULTIPLE SERVERS receive write operations simultaneous | | | | |

All databases have well defined, TCP based networking.

Other differences: which one to choose?

Here are some general guidelines for when to use a relational database:

On the other hand, here are some general guidelines for when to use a NoSQL database:

Data can be operational and analytical

Data can be structured (tables), unstructured (emails, texts, image data, social media posts), semi-structures (JSON, XML).