DS L9 Flashcards
What is a database transaction?
A logical unit of database operations which are executed as a whole for retrieving data or updating the database.
Examples include borrowing or reserving a book.
What is the purpose of transaction management?
To ensure that all updates to the database are completed successfully or none at all, maintaining data integrity.
This is achieved through a transaction log.
What are the four properties of transactions known as ACID?
- Atomicity
- Consistency
- Isolation
- Durability
These properties ensure reliable processing of database transactions.
What is atomicity in the context of transactions?
Ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted, and previous operations are rolled back.
This is crucial for maintaining the integrity of the database.
What does consistency ensure in transactions?
Any transaction brings the database from one valid state to another, ensuring data validity according to defined rules.
This includes referential integrity constraints.
What is isolation in transactions?
Enables transactions to operate independently and transparently of each other, supporting concurrent database use.
This prevents interference between transactions.
What does durability guarantee in a transaction?
Ensures that the result of a committed transaction persists in case of a system failure.
This means once a transaction is committed, it remains so even if a crash occurs.
What is a transaction log?
A record that keeps track of all transactions that update the database, storing the pre-image of records to be updated.
This log facilitates rollback in case of abnormal terminations.
What is the rollback process?
A process triggered to restore an inconsistent database to its original state using the pre-image in case of abnormal termination of a transaction.
This occurs when there is a power failure or other interruptions.
What SQL command is used to start a transaction in MySQL?
START TRANSACTION or BEGIN.
This command is necessary to initiate a transaction before executing any SQL operations.
What is concurrency control?
A mechanism that manages simultaneous operations without conflicting, ensuring database integrity.
It is essential in multi-user database environments.
What are the two major types of concurrency control?
- Pessimistic concurrency control
- Optimistic concurrency control
Each type has its own method of handling data access and conflicts.
What is pessimistic concurrency control?
A method that locks records before updates, preventing other transactions from accessing the same data simultaneously.
This approach can limit concurrency but ensures data consistency.
What is optimistic concurrency control?
A method where records are not locked, and updates are validated through a versioning mechanism.
It allows higher concurrency but requires additional checks.
What is a deadlock?
A situation where two or more transactions are waiting indefinitely for resources locked by each other.
Deadlocks can severely affect database performance.