transaction
an action or series of actions carried out by a single user or application program that reads or updates the contents of the database. Treated as a logical unit of work.
inconsistent state
data is inconsistent, occurs when referential integrity is lost
committed transaction
a transaction which has been successfully completed
aborted transaction
a transaction that is not successfully completed. in this case, the system must go back to the state it was in before the transaction began
concurrency control
the process of managing simultaneous operations on the database without having them interfere with one another
Lost update problem:
when two transactions overlap and one copies over the other
The dirty read problem:
when one transaction reads data before the other is finished. The data is "dirty", and results are wrong because of this;
Inconsistent analysis problem:
multiple fields of data are read by one transaction before another transaction can finish updating them
non repeatable (fuzzy) and phantom reads
result from one transaction running multiple times, but getting a different answer
non serial schedule
a schedule where the operations from a set of concurrent transactions are interleaved
Locking
a procedure used to control concurrent access to data. when one transaction is accessing the database, a lock may deny access to other transactions to prevent incorrect results
shared lock
if a transaction has a shared lock on a data item, it can read the item but not update it
exclusive lock
if a transaction has an exclusive lock on a data item, it can both read and update the item
2PL
two-phase locking; a transaction follows the two-phase locking protocol if all locking operations precede the first unlock operation in the transaction
Deadlock
When two programs are waiting on one another to finish with data that they each need
Timestamp
a unique identifier created by the dbms that indicates the relative starting time of a transaction.
timestamping
prioritizes transactions based on their timestamp (older transactions get priority)
database recovery
the process of restoring the database to a correct state in the event of a failure
Main properties of transactions
ACID (atomicity, Consistency, Isolation, Durability)
Atomicity
all or nothing" property, transaction is either performed in its entirety or not at all. Responsibility of the DBMS recovery system
Consistency
a transaction must change the database from one consistent state to another. responsibility of DBMS (enforcing constraints) and the application developer (doing the right thing)
Isolation
transactions execute independently. Responsibility of concurrency control system
Durability
the effects of a transaction are permanently recorded. responsibility of recovery system
Two possible outcomes for a transaction
Committed or aborted
T/F Committed transactions can be aborted
F
Compensation Transaction
Used to reverse a committed transaction
states of a transaction
active, committed, aborted, partially committed, failed
Transaction manager
coordinates transactions
schedule
module responsible for implementing a particular strategy for concurrency control
recovery manager
ensure that the database is restored to the state it was in before the transactions
buffer manager
responsible for efficient transfer of data from disk storage to main memory
three potential problems caused by concurrency
lost update problem, uncommitted dependency (dirty read) problem, inconsistent analysis problem
Serial schedule
A schedule where the operations of each transaction are executed consecutively without any interleaved operations from other transactions
T/F if the waits-for graph contains a cycle it is not conflict serializable
T
serializable schedule
A nonserial schedule where the result to the database is equivalent to a serial
schedule.
schedule
A sequence of the operations by a set of concurrent transactions that preserves the order
of the operations in each of the individual transactions.
cascading rollback
one transaction leads to a series of rollbacks
rigorous 2PL
hold all locks until end of transaction
strict 2PL
hold all exclusive locks until end of transaction
live lock
transaction is left in WAIT indefinetly
deadlock prevention
DBMS looks ahead and determines which transactions will cause deadlock
deadlock detection and recovery
allows deadlock to occur but recognizes occurrences and breaks them
lock timeouts
a transaction tat requests a lock will only wait for a set amount of time before it aborts and restarts
wait-die
DEADLOCK PREVENTION
The algorithm assigns each transaction a unique timestamp, that is ordered by time. If an older transaction requests a resource locked by a younger transaction then it is allowed to wait for the resource. If a younger transaction reque
wound-wait
DEADLOCK PREVENTION
Wound-wait algorithm actually allows older transactions to abort younger
transactions that have a resource they want. If a younger transaction requests a resource that is
allocated to an older transaction it is allowed to wait.
conservative 2PL
obtains all locks at beginning, waiting until they are all available
granularity
the size of the data items chosen as the unit of protecting (DB -> file -> page -> record -> field)
steal policy
allows the buffer manager yo write a buffer to disk before a transaction commits
force policy
ensures that all pages updated by a transaction are immediately written to disk when the transaction commits.
DBMS provided following facilities to assist with recovery:
back up mechanism, log file, checkpointing
NoSQL supported model types
key-value, document-oriented, graph database, columnar database
CAP Theorem
Consistency, Availability, Partition Tolerance
benefits of NoSQL
looser shcema definition, designed for speed and growth, lower cost, larger data sets
drawbacks of NoSQL
train staff, new companies may fail, support may be iffy
BASE
basically available, soft state, eventually consistent