Transaction:
- Indivisible unit of work
- Consists of one or more SQL statements
- Either all happens successfully or none happens at all
- Ensures that the data stored in a RDBMS remains consistent and accurate,
even in the event of errors, system failures, or other unexpected events.
ACID ensures transaction's consistency. ACID in RDBMS stands for:
A = All changes must be performed successfully or no change will happen (Atomicity)
C = Data must be consistent before and after transaction (Consistency)
I = No other process can change the data while transaction is running (Isolation)
D = The changes after transaction must persist (Durability)
Technical workings:
- BEGIN : Before the transaction query to ensure that a transaction will run
- COMMIT : After query, Statements completed successfully. New Database State persist in disk.
- ROLLBACK : In case of failure, all transaction steps are undone.