Junior — Middle
Can you explain what is meant by a transaction in the context of databases or data processing systems?
sobes.tech AI
Answer from AI
A transaction is a sequence of operations on a database that is executed as a single unit. The main properties of transactions (ACID):
- Atomicity — all operations within a transaction are either fully completed or not executed at all.
- Consistency — after the transaction completes, the database remains in a correct state.
- Isolation — concurrent transactions do not affect each other.
- Durability — after a transaction is committed, changes are saved even in case of failures.
Example: when transferring money between accounts, the amount is first deducted from one account and then added to another. If one of the operations fails, the transaction is rolled back to prevent loss of money.