Middle
What are transactions in databases?
sobes.tech AI
Answer from AI
Transactions in databases are a sequence of operations that are executed as a single unit. They ensure the properties of ACID:
- Atomicity: all operations within a transaction are either fully completed or not executed at all.
- Consistency: after a transaction is completed, the database remains in a correct state.
- Isolation: concurrent transactions do not affect each other.
- Durability: after a transaction is committed, its changes are saved even in case of failures.
Example: when transferring money from one account to another, the debit and credit must happen together; otherwise, the data will be inconsistent.