Professional Documents
Culture Documents
.
70. What are the Transaction Properties? Or list and discuss the four transaction
properties.
Transaction:
A transaction is any action that reads from and / or writes to a database. A
transaction may consists of a simple select statement to generate a list of table contents, it
may consists of update statements to change the values of attributes in various tables, it
may consists of insert statement to add rows to one or more tables, or it may consists of
combination of select, update and insert statements
In DBMS must ensure that the transactions 4 well accepted properties called as
ACID properties.
Atomicity
Meaning that the transaction cannot be subdivided, and hence, if must be processed
in its entirety or not at all. Once the whole transaction is processed, we say that the
changes are committed. If the transaction fails at any midpoint, we say that it has aborted.
Consistency
Means any database constraints that must be true before the transaction must also
be true after the transaction.
Isolation
Means changes to database are not revealed to users until the transaction is
committed.
Durability
Means changes are permanent. Thus, once a transaction is committed, no
subsequent failure of the database can reverse the effect of the transaction.
70 a)What is Serializability ?
Lost Update.
Un committed data
Inconsistency Retrieval.
Lost Update
Ex: PRODUCT table attribute is PROD_QTY. the current PROD_QTY value is 35. Assume two
concurrency transactions T1 and T2 updates the PROD_QTY value for some time in the
PRODUCT table, the transactions are
T1 purchased 100 units. T2 sells 30 units.
The following table, lost update problem can arise if both the transactions are
executed concurrently.
Note: T1 has not at been committed, T2 execution begins. Therefore T2 still operate on
value 35 and its subtraction gives 5 in memory. T1 writes the value 135 to disk which is
promptly overwrite by T2. The addition of 100 units is lost during this process.
Un committed data
T1, T2 transactions are executed concurrently and the first transaction T1 is rollback
after the completion of second transaction T2 has already accessed the uncommitted data,
thus violating the isolation property of transaction.
In the following table uncommitted data problem arise when the rollback is completed after
T2 has being executed.
Inconsistency Retrieval
When a transaction calculates some summary functions over a set of data while
other transactions are updating the data. The problem is that the transaction might read
some data before they are changed and other data after they are changed there by giving
inconsistent results.
The computer answer is 102 which is wrong, the correct answer is 92.
Database Level
The entire database is locked thus preventing the use of any tables in the database
by T2 transaction while T1 transaction is being executed.
Table Level
The entire table is locked thus preventing access to any row by transaction T2 while
transaction T1 is using the table. If a transaction requires access to several tables, each
table may be locked.
Page Level
The DBMS will lock an entire disk page. Page is the equivalent of a disk block, which
can be described as a directory addressable section of a disk.
Row Level
DBMS allows concurrent transactions to access different rows of the same table even
when the rows are located on the same page.
Field Level
Concurrent transaction to access the same row as long as they require the use of
different fields within that row.
Lock Types
There are two types. One is shared lock a technique that allows other transactions to
read but not update a record or other resources. It is also called read lock or S-lock. The
other is exclusive lock a technique that prevents another transaction from reading and
therefore updating a record until it is unlocked.
Two-phase Locking
The two-phases are growing phase, shrinking phase.
Growing phase – in which transaction acquires all required locks with out un locking any
data. Once all locks have been acquired, the transaction is in its locked point.
Shrinking phase – in which a transaction releases all locks and can not obtain any new
lock.
The two-phase locking protocol is governed by the following rules.
1. Two transactions can not have conflicting locks.
2. No unlock operation can precede a lock operation in the same transaction.
3. No data are affected until all locks are obtained, i.e. until the transaction is in its locked
point.
4. Two phase locking increases the transaction processing cost and may cause additional
undesirable effects.
T1 has not unlocked data item y, T2 can not begin; if T2 has not unlocked data item
x, T1 can not continue. Consequently T1 and T2 wait indefinitely, such a deadlock is also
known as deadly embrace.
Deadlock Prevention
A transaction requesting a new lock is aborted when there is the possibility that
deadlock can occur. The transaction is aborted, all changes made by this transaction are
rolled back and all locks obtained by the transaction are released.
Deadlock Detection
If deadlock is found, one transaction is aborted, other transaction is continued. The
DBMS periodically tests the database for deadlocks.
Deadlock Avoidance
The transaction must obtain all of the lock it needs before it can be executed.
The optimistic approach is based on the assumption that the majority of the database
operations do not conflict. The optimistic approach requires instead, a transaction is
executed with out restrictions until it is committed. Using an optimistic approach, each
transaction moves through two or three phases, referred as read, validation and write.
READ PHASE: The transaction, reads the database executes the needed computations and
makes the updates to a private copy of the database values. All update operations of the
transaction are recorded in a temporary update file, which is not accessed by the remaining
transactions.
VALIDATION PHASE: The transaction is validated to ensure that the changes made will not
affect the integrity and consistency of the database. If the validation test is positive the
transaction goes to the write phase. If the validation test is negative, the transaction is
restarted and the changes are discarded.
77. What are the three levels of backup may be used in database recovery
management.
Database recovery restore database from a given state usually inconsistent to
previously consistent state, recovery techniques are based on atomic transaction property.
DBMS provide functions that allow the database administrator to schedule automatic
database backups to permanent secondary storage device. The levels of backup are:
Differential Backup – in which, only the last modification to the database are copied.
Transaction Log Backup – which backup only the transaction log operations that are not
reflect in a previous backup copy on the database.
78. Explain about database failures. Or What are the leading causes of Data loss?
Or What are the events that cause a database In become non-operational?
A wide variety of failures can occur in processing a data base, ranging from the input
of an incorrect data value to complete loss or destruction of the data base.
1. Write-a-head log protocol – The transaction logs are always written before any
database data are actually updated.
2. Redundant Transaction Logs – DBMS keeps several copies of the transaction log
to ensure the physical disk failure problems.
3. Database Buffers – A buffer is a temporary storage area in primary memory used
to speed up disk operations and to improve processing time. DBMS software reads
the data from the disk and stores a copy on the buffer. When a transaction updates
data it actually updates in the buffer only.
4. Check point – A database checkpoint is an operation in which the DBMS writes all of
its update buffers to disk. Every checkpoint operation is registered in the transaction
log.
Transaction recovery procedures are generally two techniques deferred-write and write-
through.
A “deferred-write” or “deferred update” defines; the transaction operations do
not immediately update the physical database. Instead only the transaction log is updated.
The database is physically updated only after the transaction reaches the commit point. If
the transaction aborts before it reaches to commit point, no changes need to be made to
the database since database never updated. The recovery process for all started and
committed transactions will follow these steps.
1. Identify the last checkpoint in the transaction log. This is the last transaction data
was physically saved to disk.
2. For a transaction that started and committed before the last checkpoint, nothing
needs to be done because the data are already saved.
3. For a transaction that performed a commit operation after the checkpoint, the DBMS
uses the transaction log records to redo the transaction and to update the database.
4. For any transaction that had a rollback operation after the last checkpoint or that
was left active before the failure occurred, nothing needs to be done because the
database was never updated.
When the recovery procedure uses “write-through” or “immediate update”, the
database is immediately updated by transaction operations during the transaction
execution, even the transaction reaches its commit point. If the transaction aborts before it
reaches its commit point, a rollback operation need to perform to restore the database.
The recovery process will follow the steps: