1.3.2 transactions Flashcards
what ia a transaction?
transaction is a group of operation in a database that complete task.
problems that arise from transactions.
- concurrency:when multiple transaction are executed simultaneously, they may try to access or edit the same data causing inconsistency.
- deadlock: when two or more transaction are waiting on each other to release resources, causing them to wait indefinitely.
- data integrity: transactions may leave the database inconsistent if they fail mid execution .
isolation: in a multi-user environment a user transaction could have an effect on another user transaction. - durability: If a system fails after a transaction has been confirmed, it may result in loss of data
what is ACID
ACID are set of rules that DBMS should follow to ensure data integrity.
ACID
Atomicity:
All operations in a transaction succeed or fail as a whole
If any operation fails, the transaction is rolled back
Ensures partial transactions do not occur
Consistency:
Ensures data remains in a consistent state after transactions
Transactions must follow database rules and constraints
Starts with a consistent state and ends with a consistent state
Isolation:
Transactions are isolated from each other
Intermediate states are not visible to other transactions
Prevents conflicts and data inconsistencies
Durability:
Committed transactions persist even in case of system failures
Ensures data is not lost once a transaction is complete
record locking
It is usual for databases to be accessed by multiple people at any one time.
This can cause issues if people are trying to simultaneously access the same record. One person could accidentally overwrite the other person’s change.
Record locking avoids this by preventing anyone accessing a record in use by another person.
Redundancy
- Redundancy can occur when the same piece of data is stored in more than one table in a database. This can either be by accident or by design
- It can lead to inconsistencies in the data and/or wasted storage space