A transaction in a database refers to a unit of work that performs a single logical function,
which is a group of multiple queries bundled together.
In databases, a transaction is a series of operations or queries that form a single logical unit of work.
These operations ensure the database remains consistent by following the ACID properties:
- Atomicity
- Consistency
- Isolation
- Durability
Atomicity (원자성)
Atomicity guarantees that all the operations in a transaction are completed successfully or none are.
For example, if a transaction is committed but an error occurs requiring a rollback,
atomicity ensures that none of the partial changes persist.
Consistency (일관성)
Consistency means data must only be changed in allowed, valid ways.
All data must satisfy defined rules and constraints.
For example, if Hongchul has 10 million KRW and Beomseok has 0 KRW,
Beomseok cannot transfer 5 million KRW to someone else (assuming no overdraft).
Isolation (격리성)
Isolation ensures that concurrently running transactions do not interfere with each other.
Multiple parallel transactions should behave as if they run sequentially.
Isolation has several levels to guarantee this:
- Phantom Read: When the result of the same query differs within the same transaction.
- Non-repeatable Read: When the same row returns different values on multiple reads within a transaction.
- Dirty Read: When a transaction reads data that another transaction has modified but not yet committed.
Durability (지속성)
Durability guarantees that once a transaction is successfully committed,
its changes are permanent—even in the event of a system failure.
Databases support durability with mechanisms such as:
- Checksum
- A simple *integrity check to protect data accuracy during transmission.
- Journaling
- Logging changes before committing them to the database, enabling recovery.
*Integrity (무결성)
Integrity means maintaining data accuracy, consistency, and validity,
ensuring stored data correctly represents real-world values.
'Computer Science > Database' 카테고리의 다른 글
ERD (0) | 2025.07.25 |
---|---|
Elements that make up the database (0) | 2025.07.21 |