CS3492-DBMS Questions and Answers
CS3492-DBMS Questions and Answers
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.
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.
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.
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:
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.
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:
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.
A method like "wait for graph" 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:
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.