Wednesday, October 8, 2008

Some Interview Questions

What is meant by deadlock in database?

Transaction is unit of work done. So a database management system will have number of transactions. There may be situations when two or more transactions are put into wait state simultaneously .In this position each would be waiting for the other transaction to get released. Suppose we have two transactions one and two both executing simultaneously. In transaction numbered one we update student table and then update course table. We have transaction two in which we update course table and then update student table. We know that when a table is updated it is locked and prevented from access from other transactions from updating. So in transaction one student table is updated it is locked and in transaction two course table is updated and it is locked. We have given already that both transactions gets executed simultaneously. So both student table and course table gets locked so each one waits for the other to get released. This is the concept of deadlock in DBMS.

No comments: