SUMMER 2020 Paper Solution - DBMS
SUMMER 2020 Paper Solution - DBMS
z
f) Development & Testing Support : Helping programmer and
aa
engineer to efficiently utilise database
Aw
Q1 (B) Explain difference between Physical & Logical Data Independence
(4M)
ut
ANS
gr
ANS
Typical structure of typical DBMS is based on relational query model
z
aa
Aw
ut
gr
Ja
Storage Manager
Storage manager is the component of database system dead provide
z
interface between the low level data stored in database and the
aa
application programs and the query submitted to system
The storage manager is responsible for storing, retriving & updating
Aw
data in database
ANS
Ja
Relation
A relation is property or predicate that ranges over more than one
argument
A relation is defined as set of n tuples. In both mathematics &
relational database model
Relational Schema
A relational schema is collection of meta – data that describes
relation in database which is also called database schema
This schema can be described as “Layout” of database or blueprint
that outlines the way data is organized into table
ANS
a) Find names of suppliers who supply some red part
Πsname (σcolor = ‘red’ (suppliers))
z
(1) Graph is disconnected (2) Graph is acyclic
ANS
aa
Aw
1) Graph is disconnected
If a pair of entity sets are connected by path in an ER diagram,
ut
2) Graph is acyclic
As indicated in the answer to the previous part, a path in the
graph between a pair of entity set indicates a relationship
between two entity sets. If there is a cycle in the graph then
every pair of entity sets on cycle are related to each other in
atleast two distinct ways. If E. R diagram is acyclic then there is
unique path between every pair of entity sets & thus, a unique
relationship between every pair of entity sets
Student has a unique id, the student can enroll for multiple classes and
has a most one major. Faculty must belong to department and faculty
can teach multiple classes. Each class is taught by only faculty. Every
student will get grade for the class he/she has enrolled (7M)
ANS
z
aa
Aw
ut
gr
Ja
ANS
Normalization
Normalization is the process of organising the data in the database
Normalization is used to minimise redundancy from relation or set of
relations. It is also used to eliminate undesirable characteristics like
insertion, update and delete anomalies
z
ANS
aa
A given SQL queries translated by a query processor into lower level
Aw
programmer called an execution plan
An execution plan is a program in a functional language
The physical relational algebra extends the relational algebra with
ut
2) Optimization
3) Evaluation
2. Optimization
SQL is a very high level language :
T he user specify what to search for not how does search is
actually done
The algorithms are chosen automatically by the DBMS
For a given SQL query there may be many possible execution
plans
Amongst all equivalent plans choose the one with lowest cost
Cost is estimated using statistical information from the database
z
catalog
3. Evaluation
aa
The query evaluation engine takes a query evaluation plan,
Aw
A → BC, CD → E , B → D, E → A
Ja
ANS
From E → A, A is replaced by E
{E}+ = {E,A} E→A
= {E, A, B, C} A → BC
{E}+ = {A, B, C, D, E} B→D
OR
Q3(A) What is Normalization? Explain 3NF (3M)
z
ANS aa
Normalization
Aw
Normalization divides the larger table into smaller links them using
relationship
Ja
3NF
A relation will be in 3NF if it is in 2NF and not contain and transitive
partial dependency
3NF is used to reduce the data duplication. It is also used to achieve
the data integrity
A relation is in third normal form if it holds atleast one of following
conditions for following non – trivial functional dependency X → Y
1) X is superkey
2) X is prime attribute i.e each element of Y is part of some
candidate key
ANS
In block nested loop chain for block of outer relation all the tuples in
that block are compared with all the tuples of inner relation then
only the next block of outer relation is considered. All pair of tuples
which satisfy the condition are added in the result of join
for each block bR in BRdo
for each block bS in Bsdo
for each tuple tR in TRdo
for each tuple tS in TSdo
compare (tR, tS) if they satisfies condition
z
add them in result of join
end
aa
Aw
end
end
end
ut
In this case, total block transfers needed are similar to nested loop
join
Block nested loop join algorithm reduces access cost compared to
nested loop join if main memory space is allocated for join is limited
z
OR aa
Q3(C) Use definition of functional dependency to argue that each of
Aw
Armstrong’s axioms is sound (7M)
ANS
ut
relational database
The inference rule is a type of assertion. It can apply to a set of FD to
derive other FD
Using the inference rule, we can derive additional functional
dependency from the initial set
3) Transitive Rule
In transitive rule, if X determines Y and Y determine Z then X
must also determine Z
If X → Y, Y → Z then X → Z
z
ANS
Hashing
aa
Aw
In huge database structure, it is very insufficient to search all the
index values reached the desired data. Hashing technique is used to
calculate the direct location of data record on the disk without using
ut
index structure
In this technique, data is stored at the data blocks whose address is
gr
Q4(B) What is transaction? What are functions of commit & rollback (4M)
ANS
Transaction
A transaction is defined as group of tasks that form a single logical
units
Rollback
The rollback command is used to undo transactions that have not
already saved to database
Q4(C) Write short note on SQL injection (7M)
ANS
SQL Injection
SQL injection is a technique used to exploit user data through
z
webpage inputs by injecting SQL commands as statements
aa
Basically this statement can be used to menu plate the application
web survey by malicious user
Aw
ANS
z
B – Trees aa
B – Tree is a specialised m way tree that can be widely used for disk
Aw
access A.
B – Tree of order m can have atmost m – 1 keys and m children
One of the main reasons of using B – Tree its capability to store large
ut
ANS
Conflict Serializability
Conflict Serializability check if a non serial schedule is conflict serializable
or not. A non serial schedule is conflict serializable it can convert into
serial schedule by its non conflicting operation
Conflicting Operations
A pair of operations are said to be conflicting operations if they
follow the set of conditions given below
Both operation is a part of different transaction
Both operations get performed on the same data item
One of the performed must be write operations
z
View Serializability aa
A schedule will view serializable if it is view equivalent to serial schedule
If schedule is conflict serializable, then it will be view serializable
Aw
The view serializable which does not conflict serializable contain blind
writes
View Equivalent :
ut
following conditions
Ja
1) Initial Read
2) Update Read
3) Final Write
1) Initial Read
An initial read of both schedules must be same
Suppose two schedule S1 & S2 in S1, if transaction T1 is reading data
item A, then in SR, transaction T1 should also read A
S1 = S2
S1 ≠ S2
3) Final Write
A final write must be same between both schedules. In schedule S1,
if transaction Ti updates A at last then in S2, final write operations
should also be done by Tj
z
aa
Aw
ANS
gr
Intrusion Detection
Ja
ANS
Trigger
A trigger in structured query language is set of procedural statements
which are executed automatically when there’s any response to
certain events on particular table in the database
Trigger are used to protect the data integrity in the database
In SQL this concept is the same as the trigger in real life. For example
, when we pull gun trigger, bullet is fired
Syntax
CREATE TRIGGER Trigger_name
[Before|After] [Insert|Update|Relate]
z
ON [table_name]
[For each row|for each column]
As
aa
Aw
set of SQL statement
ANS
Declare
n1 number = &num1;
Begin
If mod(n1, 2) = 0 then
DBMS_output.put_line(‘The number ‘||n1||’ is even number’);
Else
DBMS_output.put_line(‘The number ‘||n1||’ is odd number);
End if{
DBMS_output. put_line(‘Done successfully’);
END;
z
Q5(C) Consider relational schemas :
aa
EMPLOYEE(EMPLOYEE_NAME, STREET, CITY)
Aw
WORKS(EMPLOYEE_NAME, COMPANYNAME, SALARY)
COMPANY(COMPANY_NAME, CITY) (7M)
Give an expression in SQL for each of queries below
ut
b) Find names of all employees who work for First Bank Corporation
c) Find names & company names of all employees sorted in
Ja
ANS
a) Specify table definitions in SQL
select *from EMPLOYEE;
select *from WORKS;
select *from COMPANY;
b) Find names of all employees who work for First Bank Corporation
select EMPLOYEE_NAME
FROM WORKS
WHERE COMPANYNAME = ‘First Bank Corporation’
ANS
z
Cursor
aa
Cursor is a temporary memory or temporary work station. It is
Aw
Types of Cursor
gr
2. Explicit Cursor
1) Implicit Cursor
Implicit cursors are also known as default cursors of SQL Sever.
These cursors are allocated by SQL Server when the user
perform DML operations
2) Explicit Cursor
Explicit Cursors are created by user whenever the user requires
them. Explicit Cursors are used for fetching data from table in
Row by Row Manner
ANS
declare
num number(3) : = 2;
sum number(4) : = 0;
Begin
while num < = 50 loop
dbms_output put_line(num);
sum1 : = sum1 + num;
num : = num + 2;
END loop
dbms_output put_line(‘Sum of even numbers is’ ||sum1);
END :
z
OR Q5(C) Give following relations (7M)
aa
Aw
TRAIN(NAME, START, DEST)
TICKET(PNRNO., START, DEST, FARE)
PASSENGER(NAME, ADDRESS, PNRNO)
ut
station of train
Ja
ANS
SELECT P.NAME
FROM PASSENGER P
JOIN TICKET T ON P.PNRNO = T.PNRNO
JOIN TRAIN R ON T.START = R.START AND T.DEST = R.DEST;
z
WHERE PNRNO IN (
SELECT P.PNRNO aa
FROM PASSENGER P
Aw
WHERE P.NAME = 'Tintin'
);
ut
gr
Ja