What is Transaction?
A group of database operations executed as an all-or-nothing unit, preserving consistency even when failures or concurrent access occur.
Definition
A transaction bundles multiple reads and writes into an atomic unit: either every operation commits or none do. Wrapped in BEGIN and COMMIT, a funds transfer debits one account and credits another with no possibility of half-completion, even if the server crashes mid-way — the write-ahead log guarantees recovery. Transactions also isolate concurrent work; isolation levels from Read Committed to Serializable trade throughput against anomalies like non-repeatable reads and write skew. PostgreSQL and MySQL InnoDB implement full ACID semantics, while distributed databases coordinate transactions with protocols like two-phase commit.

