Sobes.tech
Junior

Mis on tehing andmebaasidega töötamisel?

sobes.tech AI

Vastus AI-lt

A transaction in databases is a sequence of operations that is executed as a single unit. It either completes successfully (commit) or is completely rolled back (rollback) if an error occurs.

The main properties of transactions (ACID):

  • Atomicity: all operations within the transaction are either fully completed or not executed at all.
  • Consistency: the transaction moves the database from one correct state to another.
  • Isolation: parallel transactions do not affect each other.
  • Durability: after confirmation, changes remain even in case of failures.

Example: when transferring money between accounts, the debit and credit should be in the same transaction to prevent data inconsistency.

Transactions help manage concurrent access and ensure data integrity.