Friday 21 September 2012

DBMS Interview Questions-5


1. What are conflict equivalent schedules?
Ans: Two schedules are said to be conflict equivalent if the order of any two conflicting operations is the same in both schedules.

2. What is view equivalence?
Ans: Two schedules S and S’ are said to be view equivalent if the following three conditions hold :
1. Both S and S’ contain same set of transactions with same operations in them.
2. If any read operation read(x) reads a value written by a write operation or the original value of x the same conditions must hold in the other schedule for the same read(x) operation.
3. If an operation write1(y) is the last operation to write the value of y in schedule S then the same operation must be the last operation in schedule S’.

3. What is view serializable?
Ans: A schedule is said to be view serializable if it is view equivalent with some serial schedule.

4. What are the various methods of controlling concurrency?
Ans:
1. Locking: 
Locking data item to prevent multiple transactions from accessing the item concurrently. 
2. Time stamp: A time stamp is a unique identifier for each transaction, generated by the system.

5. What is a lock?
Ans: A lock is a variable associated with a data item that describes the status of the item with respect to the possible operations that can be applied to it.

6. What are various types of locking techniques?
Ans:
1. a binary lock
2. Shared/Exclusive lock
3. Two phase locking

7. What is a binary lock?
Ans: A binary lock can have two states or values:
1. locked (1)
2. unlocked(0)
If locked it cannot be accessed by any other operations, else can be.

8. What is shared or exclusive lock?
Ans: It implements multiple-mode lock. Allowing multiple accesses for read operations but exclusive access for write operation.

9. Explain two phase locking?
Ans: All the locking operations must precede the first unlock operation in the transaction .It does have two phases:
1. expanding phase (Locks are issued)
2. Shrinking phase (Locks are released)

10. What are different types of two phase lockings (2pl)?
Ans:
1. Basic
2. Conservative
3. Strict
4. Rigorous
This is the basic technique of 2pl described above.
Conservative 2pl requires a transaction to lock all the items it accesses before the transaction begins its execution, by pre-declaring it’s read-set and write-set.
Strict 2pl guarantees that a transaction doesn’t release any of its exclusive locks until after it commits or aborts.
Rigorous guarantees that a transaction doesn’t release any of its locks (including shared locks) until after it commits or aborts.

11. What is a deadlock?
Ans: Dead lock 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. Hence each transaction is in a waiting queue, waiting for one of the other transactions to release the lock on them.

12. What are triggers?
Ans: Triggers are the PL/SQL blocks definining an action the database should take when some database related event occurs. Triggers may be used to supplement declarative referential integrity, to enforce complex business rules, or to audit changes to data.

No comments:

Post a Comment