0% found this document useful (0 votes)
29 views21 pages

SUMMER 2020 Paper Solution - DBMS

H. Jay Mataji ?

Uploaded by

Jaypalsinh Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views21 pages

SUMMER 2020 Paper Solution - DBMS

H. Jay Mataji ?

Uploaded by

Jaypalsinh Rana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

DBMS SUMMER 2020 SOLUTION

Q1 (A) What are main functions of database administrator (3M)


ANS

 A database administrator (DBA) is a person who is accountable for


the environmental aspects of the database
 Generally these include :
a) Recoverability : Creating & testing backups
b) Integrity : Verifying or helping to verify data integrity
c) Security : Defining & implementing access controls to data
d) Availability : Ensuring maximum uptime
e) Performance : Ensuring maximum performance

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

Physical Data Independence Logical Data Independence


Ja

It mainly concerned about how the It mainly concerned about the


data is stored in the system structure or changing data
definition
It is easy to retrieve It is difficult to retrieve because
the data is mainly dependent on
logical structure of the data
It is concerned with the internal It is concerned with the conceptual
schema schema
Example : change in compression Example : Add/Modify or delete a
techniques, hashing algorithms new attribute
and storage device etc

Click :Youtube Channel | Free Material | Download App


Q1 (C) Explain DBMS System Architecture (7M)

ANS
 Typical structure of typical DBMS is based on relational query model

z
aa
Aw
ut
gr
Ja

 Considered the top part of the fig( ). Is shows application interfaces


used by naïve users, application programmes created by application
programmers, query tools used by sophisticated user and
administration tools used by database administrator
 The lowest part of the architecture is for disk storage

 The two important components of database architecture are


a) Query Processor
b) Storage Manager

Click :Youtube Channel | Free Material | Download App


Query Processor
 The interactive query processor helps the database system to
simplify and facilitate access to the data. It consist of DDL
interpreter, DML compiler and query evaluation engine
 DDL Interpreter : This is basically a translator which interpret DDL
statements in data dictionaries
 DML Complier : It translates DML statement query language into an
evaluation plane
 Query Evaluation Engine : It executes the low level instructions
generated by DML complier

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

Q2(A) Describe relationships in meaning between terms relation &


ut

relational schema (3M)


gr

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

Click :Youtube Channel | Free Material | Download App


Q2(B) Write the following queries in relational algebra:
a) Find the names of suppliers who supply some red part.
b) Find the IDs of suppliers who supply some red or green (4M)

ANS
a) Find names of suppliers who supply some red part
Πsname (σcolor = ‘red’ (suppliers))

b) Find IDs of suppliers who supply some red or green


ΠSID(σcolor=’red’ V color=’green’ (suppliers))

Q2(C) An ER diagram can be viewed as graph. What do following mean


in terms of an enterprise schema? (7M)

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

the entity sets related, though perhaps indirectly. A


gr

disconnected graphs implies that there are pairs of entity sets


that are unrelated to each other , if we split the graph into
Ja

connected components ,we have in effect, a separate


database corresponding to each connected component

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

Click :Youtube Channel | Free Material | Download App


OR
Q2(C) Draw ER diagram for university database consisting four entities
Student, Department, Class and Faculty.

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

Q3(A) What is Normalization? Explain 2NF? (3M)

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

Click :Youtube Channel | Free Material | Download App


 Normalization divides the larger table into smaller links them using
relationship
 The normal form is used to reduce redundancy from the database
table
2NF
 Second normal form(2NF) is based on the concept of full functional
dependency. There are 2 conditions
1) A relation that is in First Normal Form
2) Every non prime key attribute i.e Full Functionally
dependent on primary key attribute

Q3(B) Explain typical query processing strategy of DBMS (4M)

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

primitives to search through the internal storage structure of DBMS


 Steps of Query Processing
gr

1) Parsing & Translation


Ja

2) Optimization
3) Evaluation

Click :Youtube Channel | Free Material | Download App


1. Parsing & Translation
 Translate the query into its internal form. This is then translated
into relational algebra
 Parser check syntax, verifies relation

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

executes that & returns answer to that query


ut

Q3(C) Compute the closure of the following set F of functional


dependencies for relation schema R = (A, B, C, D, E). (7M)
gr

A → BC, CD → E , B → D, E → A
Ja

List out candidate keys for R

ANS

For candidate key


First check for {A}+ = {A, B, C} A → BC
= {A, B, C, D} B→D
= {A, B, C, D, E} CD → E

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

Click :Youtube Channel | Free Material | Download App


From CD → B, E is replaced by CD
{CD}+ = {C, D}
{CD}+ = {C, D, E} CD → E
= {A, C, D, E} E→A
= {A, B, C, D, E} A→B

From B → D, D is replaced by B in {CD}+


{BC}+ = {B, C, D} B→D
= {A, B, C, D, E} CD → E, E →A

Candidate Keys : A, E, CD & BC

OR
Q3(A) What is Normalization? Explain 3NF (3M)

z
ANS aa
Normalization
Aw

 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
ut

insertion, update and delete anomalies


gr

 Normalization divides the larger table into smaller links them using
relationship
Ja

 The normal form is used to reduce redundancy from the database


table

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

Click :Youtube Channel | Free Material | Download App


OR
Q3(B) Write short note on Block Nested Loop Chain (4M)

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

 Let L Look at some similar case as nested loop join


gr

 Case 1 : Assume only 2 blocks of main memory are available to


Ja

store blocks from R & S relations

For each block of relation R, we have to transfer all blocks of relation


S and each block of relation R should transferred only

Click :Youtube Channel | Free Material | Download App


 Case 2 : Assume one relation fits entirely in the main memory and
there is at least space for one extra block

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

 Armstrong’s axioms are basic inference rule


gr

 Armstrong’s axioms are use to conclude functional dependency on a


Ja

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

1) Reflexive Rule (IR1)


 In reflexive rule, If Y is subset of X then X determines Y
If X > Y then X → Y
 Example :
X = {a, b, c, d,e}
Y = {a, b,c}

Click :Youtube Channel | Free Material | Download App


2) Augmentation Rule
 Augmentation is also called a partial dependency. In
augmentation, if X determines Y, then XZ determines YZ for any Z
If X → Y then XZ → YZ
 Example :
For R(ABCD). If A → B then AC → BC

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

Q4(A) Explain hashing (3M)

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

generated by using the hashing function. The memory location where


Ja

this records are stored is known as data bucket or data blocks


 There are two types of Hashing
1) Static Hashing
2) Dynamic Hashing

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

Click :Youtube Channel | Free Material | Download App


Commit
 The commit command is used to save permanently any transaction
 When we perform read or write operations to the database then
those changes can undone by rollback operations. To make these
changes permanent, we should make use of commit

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

 SQL injection is code injection technique that might destroy your


database
 SQL injection is one of the most common web hacking techniques
ut

 SQL injection is the placement of malicious code input SQL


gr

statement via webpage input


 Example :
Ja

Suppose we have an application based on student records. Any


student can view only his or her own records by entering a unique
and a private student ID. Suppose we have a field like below
Student enters the following in the input field
1222345 or 1 = 1
So this basically translates to
select *from student where
student ID = 12222345 or 1 = 1
 Now this 1 = 1 will return all the records for which it holds true so
basically, all the students data is compromised. Now the malicious
user can also delete the student records in a similar fashion
Consider following SQL query
select *from USER where
USERNAME = “” and password = “”

Click :Youtube Channel | Free Material | Download App


Impact of SQL Injection
 The hacker can retrieve all the user data present in the database such
as user details, credit card information, Social Security numbers and
can also gain access to protected area like administrator portal
 It is possible to delete the used data from tables

Preventing SQL Injection


 User authentication : validating input from the user by predefining
length, type of input of input field and authentication users
 Do not use System Administrator account

OR : Q4(A) Explain B – Trees (3M)

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

number of keys in single node enlarge key values by keeping the


height of a tree relatively small
gr

 A B – Tree of order m contains all the properties of m – way tree.


Ja

 In addition it contains the following properties


1) Every node in B - Tree contains atmost m child
2) Every node in a B – Tree expect root node & leaf node contain
atleast m/2 children
3) The root nodes must have atleast 2 nodes
4) All leaf nodes must be at same level

Click :Youtube Channel | Free Material | Download App


OR : Q4(B) Explain Conflict Serializability & View Serializability (4M)

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

Two schedule S1 & S2 are said to be view equivalent if they satisfy


gr

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

Click :Youtube Channel | Free Material | Download App


2) Update Read
 In schedule S1 if Ti is reading A which is updated by Tj then m < 2
also Ti should read A which is updated by Tj

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

OR : Q4(C) Write short note on Intrusion Detection (7M)


ut

ANS
gr

Intrusion Detection
Ja

 An intrusion detection system(IDS) is system or software application


that monitors network traffic or system for suspicious activity or
policy violations an issue alerts when such activity is discovered
 It is a software application that scans a network order system for
harmful activity or policy breaching
 Any malicious venture or violation is normally reported to an
administrator or collected centrally using a security information and
event management system
 A SIEM system integrates output from multiple source and uses
alarm filtering techniques to differentiate malicious activity about
fake algorithms

Click :Youtube Channel | Free Material | Download App


Q5(A) What is Trigger? Explain its type with their syntax(3M)

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

Types of Trigger in SQL


ut

1. After Insert Trigger :


This trigger is invoked after insertion of data in table
gr
Ja

2. After Update Trigger :


This trigger is invoked in SQL after modification of data in table

3. After Delete Trigger :


This trigger is invoked after deleting data from table

4. Before Insert Trigger :


This trigger is invoked before inserting record in table

5. Before Update Trigger :


This trigger is invoked before updating record in table

6. Before Delete Trigger


This trigger is invoked before deleting record from table

Click :Youtube Channel | Free Material | Download App


Q5(B) Write a PL/SQL block to print given number is odd or even (4M)

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

a) Specify table definitions in SQL


gr

b) Find names of all employees who work for First Bank Corporation
c) Find names & company names of all employees sorted in
Ja

ascending order of company name & descending order of


employees name of that company
d) Change city of First Bank Corporation to ‘New Delhi’

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’

Click :Youtube Channel | Free Material | Download App


c) Find names & company names of all employees sorted in ascending
order of company name & descending order of employees name of
that company
SELECT EMPLOYEE_NAME, COMPANYNAME
FROM WORKS
ORDER BY COMPANYNAME ASC, EMPLOYEE_NAME DESC;

d) Change city of First Bank Corporation to ‘New Delhi’


UPDATE COMPANY
SET CITY = 'New Delhi'
WHERE COMPANY_NAME = 'First Bank Corporation';

OR Q5(A) Explain cursor & its types (3M)

ANS

z
Cursor
aa
 Cursor is a temporary memory or temporary work station. It is
Aw

allocated by database server at time of performing DML operations


on table by user
 Cursor are used to store Database Tables
ut

Types of Cursor
gr

 There are 2 types of Cursor


1. Implicit Cursor
Ja

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

Click :Youtube Channel | Free Material | Download App


OR Q5(B) Write a PL/SQL block to print sum of even numbers from 1 to 50

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

Write SQL expressions of following queries :


a) List names of passengers who are travelling from start to destination
gr

station of train
Ja

b) List names of passengers who have return journey ticket


c) Insert new Shatabti train from Delhi to Bangalore
d) Cancel ticket of Tintin

ANS

a) List names of passengers who are travelling from start to destination


station of train

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;

Click :Youtube Channel | Free Material | Download App


b) List name of passengers who have return journey ticket
SELECT DISTINCT P.NAME
FROM PASSENGER P
JOIN TICKET T1 ON P.PNRNO = T1.PNRNO
JOIN TICKET T2 ON T1.PNRNO = T2.PNRNO
WHERE T1.START = T2.DEST AND T1.DEST = T2.START;

c) Insert new Shabati train from Delhi to Bangalore


INSERT INTO TRAIN (NAME, START, DEST)
VALUES ('Shatabti', 'Delhi', 'Bangalore');

d) Cancel ticket of Tintin


DELETE FROM TICKET

z
WHERE PNRNO IN (
SELECT P.PNRNO aa
FROM PASSENGER P
Aw
WHERE P.NAME = 'Tintin'
);
ut
gr
Ja

Click :Youtube Channel | Free Material | Download App

You might also like