Databases
SQL Databases
SQL (Structured Query Language) databases are relational databases that store data in tables with predefined schemas. They use SQL for querying and manipulating data, ensuring ACID (Atomicity, Consistency, Isolation, Durability) transactions.
NoSQL Databases
NoSQL (Not only SQL) databases are non-relational databases designed for flexibility, scalability, and performance. They store data in flexible schemas like key-value pairs, documents, or graphs, and use various query languages.
SQL vs NoSQL
Characteristic | SQL Databases | NoSQL Databases |
---|---|---|
Schema | Requires a predefined schema with fixed tables and columns. | Adaptable schemas that can evolve over time. |
ACID Compliance | Ensures data integrity through transactions. | Emphasizes availability and partition tolerance over strong consistency (BASE). |
Data Model | Relational model with tables and relationships using foreign keys. | Supports various data models like key-value, document, or graph. |
Query Language | Uses SQL (Structured Query Language) for querying and manipulating data. | Supports different query languages depending on the database type (not limited to SQL). |
Scalability | Primarily scales vertically (increasing hardware resources like CPU and RAM). | Scales horizontally by adding more servers (nodes) to the database cluster. |
Examples | MySQL, PostgreSQL, Oracle. | MongoDB, Cassandra, Redis. |
Use Cases |
|
|
The choice between SQL and NoSQL databases depends on specific application requirements, including data structure, scalability needs, performance goals, and consistency requirements. Many modern applications use both SQL and NoSQL databases in a polyglot persistence approach to leverage the strengths of each.