DELAPARRA
Index
Color
NL
Category: SQL

ACID

Explained by Updated

What is ACID?

ACID: The four guarantees a transactional database gives: Atomicity, Consistency, Isolation, Durability. ACID describes four guarantees of database transactions. Atomicity means all changes in a transaction happen, or none do. Consistency means rules such as foreign keys and constraints hold afterwards. Isolation means parallel transactions do not see each other's unfinished work. Durability means committed data survives a crash.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about ACID

How is ACID used in practice?

The standard example is a bank transfer. Money leaves one account and arrives in another. If the system crashes halfway, atomicity ensures you do not end up with money that vanished.

What should you keep in mind with ACID?

In application code, use a transaction whenever several writes belong together, such as creating an order and its order lines. In Laravel that is DB::transaction(function () { ... }). If any step throws an exception, everything is rolled back. Keep transactions short, though, because long ones hold locks and slow down everyone else.

What does an example of ACID look like?

-- Atomic: both or neither BEGIN; UPDATE accounts SET bal = bal - 100 WHERE id = 1; UPDATE accounts SET bal = bal + 100 WHERE id = 2; COMMIT;

At a glance

CategorySQL
Explained by
Updated

More SQL terms

All terms starting with A

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.