ACID is a set of properties of DatabaseDatabase
Databases are computer systems designed for storing data.
This note serves as a link to connect database-related notes.
[[ACID]]
Optimistic LockingOptimistic Locking
Optimistic Locking in [[Database]] systems is a locking mechanism that relies on data versions to stop updates based on stale data.
For example:
user A fetches account data which says amount: 1.../Pessimistic LockingPessimistic Locking
Pessimistic Locking in [[Database]] systems is a locking mechanism that relies on exclusive locks to ensure two transactions don't update rows at the same time.
For example:
user A fetches acco...
Status: #🌱... systems that talks about how a database transaction should behave in order for it to be considered reliable. It stands for:
A
tomicityC
onsistencyI
solationD
urability
Atomicity
Atomicity says that either the transaction is executed in its entirety, or the database must be in an untouched state if the transaction has failed - nothing in between.
Imagine having a database transaction consisting of two queries:
- one to deduct money from account A
- one to add money to the account B
It would be pretty inconvenient for us to be able to mistakenly deduct money from A without actually adding it to B. Atomicity just says that this database guarantees that either both queries will be completed without issues, or the database will be returned to the state before this transaction was issued.
Consistency
Consistency just says that when we write into a database, any constraints we have on the data must be followed, and any cascades or triggers executed - otherwise the transaction will fail. At the end of the transaction, data in our database must be consistent.
Isolation
Isolation states that if we have two concurrently-running transactions, database guarantees us that neither of them will be influenced by one another - they will both be executed in total isolation.
Any concurrent transactions touching the same data must be resolved in a sequential-like manner. If this is not possible, databases resolve this either through Optimistic LockingOptimistic Locking
Optimistic Locking in [[Database]] systems is a locking mechanism that relies on data versions to stop updates based on stale data.
For example:
user A fetches account data which says amount: 1... or Pessimistic LockingPessimistic Locking
Pessimistic Locking in [[Database]] systems is a locking mechanism that relies on exclusive locks to ensure two transactions don't update rows at the same time.
For example:
user A fetches acco....
Durability
Durability states that the moment transaction is commited, it's submitted to the persistent storage. If a crash occurs a mere moment after the transaction was successful, we are guaranteed that our transaction is not lost.
Status: #🌱