DBMS Question Bank For 3rd IAT
DBMS Question Bank For 3rd IAT
ACID properties
· Atomicity
A transaction is an atomic unit of processing; it is either performed in its
entirety or not performed at all.
· Consistency preservation
· Isolation
The execution of a transaction should not be interfered with by any other
transactions executing concurrently
· Durability
The changes applied to the database by a committed transaction must persist
in the database. These changes must not be lost because of any failure
b) What is Concurrency? Explain the types of problem during occurs due concurrency.
DBMS has a Concurrency Control sub-system to assure database remains in consistent state
despite concurrent execution of transactions
Lock
• Describes status of the data item with respect to operations that can be
performed on it
Types of locks
• Binary locks
• Locked/unlocked
Multiple-mode locks:
3. Unlock
Transaction is said to follow the two-phase-locking protocol if all locking operations precede the
first unlock operation
• Shrinking phase
• Downgrading ok
• Upgrading is not
2PL Example
• Both T1’ and T2’ follow the 2PL protocol
• Any schedule including T1’ and T2’ is guaranteed to be serializable
• Limits the amount of concurrency
• Two-phase locking protocol (2PL)
All lock operations precede the first unlock operation
• Expanding phase and shrinking phase
• Upgrading of locks must be done in expanding phase and downgrading of
locks must be done in shrinking phase
• If every transaction in a schedule follows 2PL protocol then the schedules is
guaranteed to be serializable.
• Variants of 2PL
Basic, conservative, strict, and rigorous
3 a) List the transaction states. Draw and explain state transition diagram of the transaction.
Transaction states
5. When the deadlock and Starvation occurs? Explain these problems can
resolved.
Deadlocks and Starvation in 2PL
Deadlock occurs when each transaction T in a set of two or more transactions is waiting
for some item that is locked by some other transaction T’ in the set.
Wait-die
An older transaction is allowed to wait on a younger transaction whereas a younger
transaction requesting an item from held by an older transaction is aborted and restarted with
the same timestamp
Wound-wait
Starvation
A transaction cannot proceed for an infinite period of time while other transactions in the
system continue normally
• Victim selection
5. How to recover the transaction from failure? Explain the list of recovery concepts.
• Alternatives:
– undo/no-redo
– no-undo/redo
– undo/redo
– no-undo/no-redo.
Backup
Cache
Rollback
• read-TS(X)
• write-TS(X)
• T issues a write(X)
• If read-TS(X) > TS(T) or if write-TS(X) > TS(T) the abort and rollback
T and reject the operation.
• If condition above does not occur then execute the operation and set
write-TS(X) = TS(T)
• T issues a read(X)
• If write-TS(X) > TS(T) then abort and rollback T and reject the
operation.
• Strict TO ensures that the schedules are both strict (for easy recoverability)
and (conflict) serializable
• It rejects fewer write operations, by modifying the basic TO checks for the
write-item(X) operation as follows:
1. If read-TS(X) > TS(T), then abort and roll back T and reject the
operation.
2. If write-TS(X) > TS(T), then do not execute the write operation but
continue processing.
[This is because some transaction with timestamp greater than
TS(T)—and hence after T in the timestamp ordering—has already
written the value of X. Hence, we must ignore the write_item(X)
operation of T because it is already outdated and obsolete. Notice that
any conflict arising from this situation would be detected by case (1).]
3. If neither the condition in part (1) nor the condition in part (2) occurs,
then execute the write-item(X) operation of T and set write-TS(X) to
TS(T).
A relation schema R is in 4NF with respect to a set of dependencies F (that includes functional
dependencies and multivalued dependencies) if, for every nontrivial multivalued dependency X
—>> Y in F+, X is a superkey for R.
c)The relation SUPPLY with no MVDs is in 4NF but not in 5NF if it has the JD(R1, R2, R3). (d)
Decomposing the relation SUPPLY into the 5NF relations R1, R2, and R3
For a table to satisfy the Fourth Normal Form, it should satisfy the following two conditions:
1 Science Cricket
1 Maths Hockey
2 C# Cricket
2 Php Hockey
1. As you can see in the table above, student with s_id 1 has opted for two courses, Science and
Maths, and has two hobbies, Cricket and Hockey.
Fifth normal form (5NF)
A relation schema R is in fifth normal form (5NF) (or Project-Join Normal Form (PJNF)) with
respect to a set F of functional, multivalued, and join dependencies if, for every nontrivial join
dependency JD(R1, R2, ..., Rn) in F+ (that is, implied by F), every Ri is a superkey of R.
o In the above table, John takes both Computer and Math class for Semester 1 but he doesn't
take Math class for Semester 2. In this case, combination of all these fields required to
identify a valid data.
o Suppose we add a new Semester as Semester 3 but do not know about the subject and who
will be taking that subject so we leave Lecturer and Subject as NULL. But all three columns
together acts as a primary key, so we can't leave other two columns blank.
o So to make the above table into 5NF, we can decompose it into three relations P1, P2 & P3:
Lossless Decomposition
● If the information is not lost from the relation that is decomposed, then the decomposition
will be lossless.
● The lossless decomposition guarantees that the join of relations will result in the same
relation as it was decomposed.
● The relation is said to be lossless decomposition if natural joins of all the decomposition
give the original relation.
} The idea is to specify (theoretically, at least) the “ultimate normal form” that takes into
account all possible types of dependencies and constraints. .
ii)Template Dependency
An inclusion dependency R.X < S.Y between two sets of attributes—X of relation schema R,
and Y of relation schema S—specifies the constraint that, at any specific time when r is a
relation state of R and s a relation state of S, we must have
pX(r(R)) Ê pY(s(S))
To formalize two types of interrelational constraints which cannot be expressed using F.D.s or
MVDs:
} Class/subclass relationships
for 1 ≤ i ≤ n.
IDIR3 (transitivity): If R.X < S.Y and S.Y < T.Z, then R.X < T.Z.
Shadow paging
Assumes an indirect addressing scheme:
References to database objects consist of
<page-no, slot-no> pairs, where page-no is
the index to a page table (’directory’), which contains the true physical addresses.
Advantages:
• Simple recovery, no log in single-user systems (in multi-user systems, logs and
checkpoints needed for concurrency control).
Disadvantages:
• Fragmentation of storage (clustering lost).
Immediate update
• Updated values from the buffer first to the log, then to the database (even before
commit);
WAL-rule
• Two alternatives:
DBMS has a Concurrency Control sub-system to assure database remains in consistent state despite
concurrent execution of transactions
The DBMS must not permit some operations of a transaction T to be applied to the database while
other operations of T are not, because the whole transaction is a logical unit of database processing. If
a transaction fails after executing some of its operations but before executing all of them, the
operations already executed must be undone and have no lasting effect. Types of Failures. Failures are
generally classified as transaction, system, and media failures. There are several possible reasons for a
transaction to fail in the middle of execution:
1. A computer failure (system crash). A hardware, software, or network error occurs in the computer
system during transaction execution. Hardware crashes are usually media failures—for example, main
memory failure.
2. A transaction or system error. Some operation in the transaction may cause it to fail, such as integer
overflow or division by zero. Transaction failure may also occur because of erroneous parameter
values or because of a logical programming error.3 Additionally, the user may interrupt the transaction
during its execution.
3. Local errors or exception conditions detected by the transaction. During transaction execution,
certain conditions may occur that necessitate cancellation of the transaction. For example, data for the
transaction may not be found. An exception condition, such as insufficient account balance in a
banking database, may cause a transaction, such as a fund withdrawal, to be canceled. This exception
could be programmed in the transaction itself, and in such a case would not be considered as a
transaction failure.
4. Concurrency control enforcement. The concurrency control may abort a transaction because it
violates serializability ,or it may abort one or more transactions to resolve a state of deadlock among
several transactions (see Section Transactions aborted because of serializability violations or
deadlocks are typically restarted automatically at a later time.
5. Disk failure. Some disk blocks may lose their data because of a read or write malfunction or
because of a disk read/write head crash. This may happen during a read or a write operation of the
transaction. 6. Physical problems and catastrophes. This refers to an endless list of problems that
includes power or air-conditioning failure, fire, theft, sabotage, overwriting disks or tapes by mistake,
and mounting of a wrong tape by the operator.