TOOGLE
noSQL - Database
ACID Theorem - Characteristics of Relational Databases
Atomicity: In a transaction with multiple steps, either all steps complete or none do. The steps are part of the same atomic core

Consistency: Ensures that queries receive the latest transaction. Queries are consistent with the most recent data changes.

Isolation: If two operations are launched simultaneously, both are executed successfully. They are executed in isolation.

Durability: Ensures that an action that has been elected will be executed, even if the system fails. Every action will be durable.

Other Terms:
Commit: Accepts and ensures a transaction. Goes from one valid state to another.

Rollback: Returns the database to the last valid state.

Disadvantages of SQL:
Rigid schemas: Data cannot change as the data structure is defined at the start.

Volume of data: Current data volumes are larger than these networks can support.

Scalability: Scalability is more complex and designed to scale vertically, which eventually hits a limit.

Costs: Large relational databases are very vertical, implying significant implementation and maintenance costs.

Nature of data: Only works with structured data, while most data generated today is semi-structured or unstructured.

Difference between SQL and NoSQL
NoSQL:
Generally use a horizontally and partitioned scale.

Do not use SQL as a query language.

Flexible schemas. No initial definition of data structure is required.

Do not guarantee the ACID theorem but are defined by the BASE model.

Do not allow operations as complex as in SQL.

BASE Model:
BA (Basic Availability): Data availability even in the presence of failures due to data replication.

S (Soft State): Not all servers are consistent with each other, not all nodes have the same data.

E (Eventual Consistency): Does not guarantee that we retrieve the last value. When querying data, we may receive the previous value.

Important Difference between ACID and BASE:
ACID - Pessimistic locking: When the transaction is initiated, the object is completely locked.

BASE - Optimistic locking: When the transaction is initiated, the object is not locked, but its initial state is stored. After the commit, the old and new data are compared.

Types of NoSQL Databases:
Key-Value

Columns

Documents

Graphs

NoSQL Databases in Compliance with the CAP Theorem:
Consistency, Availability, Partition Tolerance:

Organize and translate into English
Consistency (C): All nodes see the same data at the same time.

Availability (A): Every request gets a response on success/failure.

Partition Tolerance (P): The system continues to operate despite network partitions or node failures.

CAP Theorem:
Consistency: Every read receives the most recent write or an error.

Availability: Every request receives a response, without the guarantee that it contains the most recent write.

Partition Tolerance: The system continues to operate despite network partitioning.

Example of the CAP Theorem in Action:
In a distributed system, if a network partition occurs (P), the system must choose between being consistent (C) or available (A).
Conclusion:
SQL databases are ACID compliant, with a focus on consistency.

NoSQL databases adhere to the BASE model, providing more flexibility and scalability at the cost of some consistency.

The CAP theorem is a crucial consideration for designing distributed systems, balancing the trade-offs between consistency, availability, and partition tolerance.