0% found this document useful (0 votes)
360 views

CS3492-DBMS Questions and Answers

The two potential pitfalls of lock-based concurrency control protocols are deadlock and starvation. Deadlock occurs when two or more transactions are waiting for resources held by each other, forming a cyclic wait. Starvation can occur if the concurrency control manager is poorly designed, allowing some transactions to repeatedly be denied locks and unable to complete. Concurrency control managers can be designed to prevent starvation through mechanisms like priority ordering of transactions. The document discusses concurrency control methods like locking protocols, discusses issues like deadlocks and starvation, and provides examples of SQL queries and their translation to relational algebra. It also covers topics like fragmentation, information retrieval processes, and examples of queries on sample databases.

Uploaded by

Shalini K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
360 views

CS3492-DBMS Questions and Answers

The two potential pitfalls of lock-based concurrency control protocols are deadlock and starvation. Deadlock occurs when two or more transactions are waiting for resources held by each other, forming a cyclic wait. Starvation can occur if the concurrency control manager is poorly designed, allowing some transactions to repeatedly be denied locks and unable to complete. Concurrency control managers can be designed to prevent starvation through mechanisms like priority ordering of transactions. The document discusses concurrency control methods like locking protocols, discusses issues like deadlocks and starvation, and provides examples of SQL queries and their translation to relational algebra. It also covers topics like fragmentation, information retrieval processes, and examples of queries on sample databases.

Uploaded by

Shalini K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CS3492-DATABASE MANAGEMENT SYSTEM

PART –A
1.What are the two pitfalls of lock-based protocols ?

The potential for deadlock exists in most locking protocols. Deadlocks are a necessary evil.

• Starvation is also possible if concurrency control manager is badly designed.

For example: – A transaction may be waiting for an X-lock on an item, while a sequence of other
transactions request and are granted an S-lock on the same item. – The same transaction is repeatedly
rolled back due to deadlocks.

• Concurrency control manager can be designed to prevent starvation.

2.Consider the transactions 1,2 and 3 for adding factorial operations.Find the total number of
schedules possible along with total number of serial schedules and non serial schedules possible.

Solution – Total Number of Schedules,= (1 + 2 + 3)! / (1! * 2! * 3!) = 6! / 12 = 60

Number of Serial Schedules,= 3! = 6


Number of Non-Serial Schedules= Total Number of Schedules - Number of Serial Schedules
= 60 - 6
= 54
3. Compare the algorithms used for deadlock avoidance.
Description Wait/Die Wound/Wait
Older process needs a resource Older process waits Younger process dies
held by younger process
Younger process needs a Younger process dies Younger process dies
resource held by older process

4.List the three main methods of concurrency control.

The three methods of concurrency control are as follows:

 Locking Methods

 Time-stamp Methods

 Optimistic Methods
5.Write about linear probing.

 The simplest approach to resolve a collision is linear probing. In this technique, if a value is
already stored at a location generated by h(k), it means collision occurred then we do a
sequential search to find the empty location.
 Here the idea is to place a value in the next available position. Because in this approach searches
are performed sequentially so it’s known as linear probing.
 Here array or hash table is considered circular because when the last slot reached an empty
location not found then the search proceeds to the first location of the array.

6.Write the SQL queries for student database, translate those queries into relational algebra.

Database:

Students: (studentID, firstname, familyname, address, borough)


Entries: (studentID, examID< result)
Exams: (examID, examName, qualification, board, date)
SQL query:

SELECT studentID
FROM Students s, Entries e, Exams x
WHERE s.studentID = e.studentID AND e.examID = x.examID AND
s.borough='Haringey' AND e.result = 'pass' AND x.examName='Latin'

I have to re-express this query in relational algebra where the joins are performed on the tables after
the tables have been reduced by the selection operators
my answer
PROJECTstudentID(SELECTs.borough='Haringey'(Students)) EQUIJOIN s.studentID=e.studentID((SELECTe.result='pass'(Entries))
EQUIJOIN e.examID=x.examID (SELECTx.examName='Latin'(Exams)))

7.How SQL injection vulnerability works around a simple web application having two input fields..

To make an SQL Injection attack, an attacker must first find vulnerable user inputs within the web page
or web application. A web page or web application that has an SQL Injection vulnerability uses such user
input directly in an SQL query. The attacker can create input content. Such content is often called a
malicious payload and is the key part of the attack. After the attacker sends this content, malicious SQL
commands are executed in the database.

8.What are the advantages of fragmentation?

 The advantage of fragmentation is that there are no data copies, which prevents data
inconsistency. 
 Vertical fragmentation can increase efficiency if clusters of “frequently” used and “rarely” used
attributes can be identified. Frequently used attributes can be stored in the table corresponding
to the entity and rarely used attributes can be stored in a separate table.
9.Sketch the information retrieval process.

Information retrieval (IR) may be defined as a software program that deals with the organization,
storage, retrieval and evaluation of information from document repositories particularly textual
information. 

10.Write a query for employee table in that list the name of employees who have two or more
dependents.

Database:

EMPLOYEE (FNAME, MINIT, LNAME, SSN, BDATE, ADDRESS, SEX, SALARY,#SUPERSSN, #DNO)
DEPARTMENT (DNAME, DNUMBER, #MGRSSN, MGRSTARTDATE)
DEPT_LOCATIONS (#DNUMBER, DLOCATION)
PROJECT (PNAME, PNUMBER, PLOCATION, #DNUM)
WORKS_ON(#ESSN, #PNO, HOURS)
DEPENDENT (#ESSN, DEPENDENT_NAME, SEX, BDATE, RELATIONSHIP)

Query:

Retrieve the names of all employees who have two or more dependents
SELECT LNAME, FNAME
FROM EMPLOYEE
WHERE
(SELECT
COUNT (*)
FROM
DEPENDENT
WHERE
SSN = ESSN) >= 2
PART – B
11.(a)(i)

T1 X(A) S(D)
T2 S(A)
T3 X(B) S(C) X(A)
T4 X(C) X(A)
T5 S(D) X(B)
Do any of the above transactions are in deadlock. If so,mention them. Show by example how
deadlocks can be avoided and prevented.

SOLUTION:

There is no deadlock.The “wait-for” graph has the following edges:

 T2 to T1 (S(A) conflicts with X(A))


 T5 to T3 (X(B) conflicts with X(B))
 T3 to T1 (X(B) conflicts with X(B))
 T4 to T1(X(B) conflicts with X(B))

The graph has no cycles .So,there are no deadlocks.

Deadlock Avoidance: When a database is stuck in a deadlock state, then it is better to avoid the
database rather than aborting or restating the database.

 This is a waste of time and resource. It is not good approach to abort a transaction whena deadlock
occurs.

 Deadlock avoidance should be used to detect any deadlock situation in advance.

 A method like &quot;wait for graph&quot; is used for detecting the deadlock situation but this
method is suitable only for the smaller database. For the larger database, deadlock prevention method
can be used.

Deadlock prevention:

 For large database, deadlock prevention method is suitable.

 A deadlock can be prevented if the resources are allocated in such a way that deadlock never occur.

 The DBMS analyzes the operations whether they can create deadlock situation or not, If they do, that
transaction is never allowed to be executed.

 Deadlock prevention mechanism proposes two schemes : Wait-Die scheme and Wound wait scheme
11.(a).(ii).Explain ACID properties with an example.

You might also like