Dma S17 PDF
Dma S17 PDF
Dma S17 PDF
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Page 1 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
4. Natural Join( ⋈) 1M
5. Union(U) each
6. Set Difference ( – )
7. Rename (ρ)
(d) Define Group by clause. 2M
Ans. The SQL GROUP BY clause is used along with the SQL aggregate
functions and specifies the groups where selected rows are placed. Descript
When one or more aggregate functions are presented in the SQL ion 2M
SELECT column list, the SQL GROUP BY clause calculates a
summary value for each group.
(e) What is SQL? State its features. 2M
Ans. SQL is an acronym for Structured Query Language an is a standard
relational query language used for creating and manipulating Descript
databases. ion 1M
Features of SQL are:
SQL allows the user to create, update, delete, and retrieve data Any two
from a database. features
SQL is very simple and easy to learn. :½M
SQL works with database programs like DB2, Oracle, each
MS Access, Sybase, MS SQL Sever etc.
(f) Define index. 2M
Ans. Index: An index is a schema object that can speed up the retrieval of
rows by using pointer. An Index provides direct and fast access to Definiti
rows in a table. on 2M
(g) Define cursor. 2M
Ans. The Oracle Engine uses a work area for its internal processing in
order to execute an SQL statement. This work area is private to Definiti
SQL’s operations and is called a Cursor. on 2M
OR
A cursor is a temporary work area created in the system memory
when a SQL statement is executed.
(h) List advantages of Normalization. 2M
Ans. Advantages of the normalization.
More efficient data structure. Any two
Avoid redundant fields or columns. advanta
More flexible data structure i.e. we should be able to add new rows ges 1M
and data values easily each
Better understanding of data.
Page 2 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Page 3 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
3. The full outer join keyword returns all records when there is a
match in either left (table1) or right (table2) table records.
Page 4 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
END;
DECLARE
s_rollNostudents.rollNo%type := 10;
s_namestudents.name%type; Exampl
s_addressstudents.address%type; e 2M
BEGIN
SELECT rollNo, name, address FROM students WHERE rollNo =
s_rollNo; dbms_output.put_line(s_rollNo || ' ' || s_name || ' ' ||
s_address);
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('No such student!');
WHEN others THEN
dbms_output.put_line('Error!');
END;
2. Attempt any FOUR of the following: 16
(a) Explain referential integrity constraints with example. 4M
(Note: Any other example can be considered)
Ans. Referential integrity constraint:
It is used to established a parent child relationship between
two tables. Descript
A value of foreign key is derived from the primary key. ion 2M
Primary key is defined in a parent table and foreign key is
defined in child table. The child table contains the values for
foreign key column which are present in parent tables primary
key column but not other than that.
Syntax:
Create table tablename (column datatype size references
parenttablename (primary key attribute)….)
Example:
Create table product (EmpId number (4) references Emp (EmpId), Exampl
PName varchar2(10)); e2M
Page 5 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Any 2
String
function
s 1M
each
Page 6 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Any 2
date
time
function
s 1M
each
Page 7 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
BEGIN
LOOP
dbms_output.put_line(x);
x := x +1;
IF x >60 THEN
exit;
END IF;
END LOOP;
END;
(f) List and explain types of DBMS users. 4M
Ans. List of DBMS user:
a) Naive users
b) Application programmers
c) Sophisticated users List
d) Specialized users 1M
e) Database administrator
Explanation:
a) Naive User: Explana
Naïve users are unsophisticated users tion of
They are interact with the system through the application any 3
program. 1M each
They give data as input through application program or get
output data which is generated by
application program.
Example: Bank cashier.
b) Application programmers:
Application programmers are the users who write the
program.
These programmers use programming tools to develop the
program.
RAD technology is used to write the program.
c) Sophisticated users:
Sophisticated users interact with the system by making the
requests in the form of query
language.
These queries are then submitted to the query processor.
Query processor converts the DML statements into lower
Page 8 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Example:
SQL > SELECT ID, NAME, AGE, ADDRESS, MIN(SALARY) Exampl
FROM CUSTOMERS e 2M
GROUP BY ID
HAVING MIN(SALARY)>=2000;
(b) Explain implicit and explicit cursor. 4M
Ans. Implicit Cursor:
Implicit cursors are automatically created by Oracle whenever an
SQL statement is executed, when there is no explicit cursor for the
Page 9 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
statement.
Whenever a DML statement (INSERT, UPDATE and DELETE) is
issued, an implicit cursor is associated with this statement. For
INSERT operations, the cursor holds the data that needs to be
inserted. For UPDATE and DELETE operations, the cursor identifies
the rows that would be affected.
In PL/SQL, implicit cursor as has the attributes like %FOUND,
%ISOPEN, %NOTFOUND, and %ROWCOUNT.
Descript
Example of implicit cursor: ion or
Begin example
Update emp set salary= salary +500 where empno =&empno; 2M for
If SQL%FOUND then each
Dbms_out.put_line(―Emp table modified‖); type
Else
Dbms_out.put_line(―Emp table modified‖);
End if;
End;
Explicit cursor:
Explicit cursors are programmer defined cursors for gaining more
control over the context area.
An explicit cursor should be defined in the declaration section of the
PL/SQL Block. It is created on a SELECT Statement which returns
more than one row.
Page 10 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
ecode emp.empno%Type;
sal emp.salary%Type;
Begin
Open c1;
If c1%ISOPEN then
Loop
Fetch c1 into ecode,sal;
If c1% NOTFOUND then Exit;
End if;
Update emp set salary = salary+500;
End Loop;
Close c1;
Else dbms_out.put_line(―unable to open‖);
End if;
End;
(c) Explain strong and weak entity set with example. 4M
Ans. Strong Entity Set: An entity set that has sufficient attributes to form
a primary key iscalled as strong entity set.
Exampl
e 1M
each
(diagra
m
optional
)
Page 11 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Example:
CREATE OR REPLACE TRIGGER trg1
Page 12 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Page 13 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Correct
use of
symbols
2M
OR Correct
entities
and
relation
ships
2M
Page 14 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
(ii) Function:
Example:
This function returns the total number of CUSTOMERS in the
customers table.
RETURN total;
END;
/
Page 15 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Rollback:
The ROLLBACK command is used to undo transactions that have
not already been saved to the database.
The ROLLBACK command can only be used to undo transactions
since the last COMMIT or ROLLBACK command was issued.
Syntax
We can either rollback the entire transaction or till a particular save 1M each
point transaction can be rolled back.
The syntax for ROLLBACK is:
ROLLBACK TO SAVEPOINT_NAME;
OR
ROLLBACK;
OR
ROLLBACK WORK;
(d) Consider the structure for book table as Book-master = {bookid, 4M
bookname, subcode-author, no_of copies, price} Write SQL
queries for following:
(i) Display total no. of books for subject ‘DBM’
(ii) Get authorwise list of all books.
(iii) Display all books whose prices are between Rs.200 and
Rs.500
(iv) Display all books with details whose name start with ‘S’
(Note: Queries with any other correct logic shall be considered) Each
Ans. (i)select sum(no_of Copies) from Book_master where subcode= correct
‘ DBM’; query
(ii) Select SUM(no_of Copies),author from Book_master group by 1M
(author);
(iii) Select bookname from book_master where price>=200 and price
Page 16 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
<=500;
(iv) select * from book_master where bookname like ‘S%’;
Page 17 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Page 18 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
tables.
Example :
Operations on snapshot:
i) Creating Snapshot:
Create snapshot command is used to create the snapshot.
Syntax:- Any one
CREATE SNAPSHOT [schema.] <snapshot name>AS subquery; operatio
Example:- ns
Create snapshot emp_snapas select * from emp where example
deptno=6; :2M
Page 19 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Example :
DECLARE
p VARCHAR2(30); Exampl
n PLS_INTEGER := 37; e 2M
BEGIN (any
FOR j in 2..ROUND(SQRT(n)) LOOP other
IF n MOD j = 0 THEN example
p := ' is not a prime number'; consider
GOTO print_now; ed)
END IF;
END LOOP;
p := ' is a prime number';
<<print_now>>
DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || p);
END;
(d) Explain PL/SQL block structure. 4M
Ans. Block structure of PL/SQL:
Declare Correct
block
Declaration of memory variables
structur
BEGIN (Mandatory) e 3M
SQL executable statements
Exception
Page 20 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Handling errors
END; (Mandatory)
A block begins with a declarative section where variables are
declared. This is followed by a section containing the procedural Explana
statements surrounded by BEGIN and END keywords. Each block tion 1M
must have Begin and End statements and may optionally include an
exception section to handle errors. End section marks the end of PL-
SQL block
(e) Explain candidate key and primary key. 4M
Ans. Candidate key:
In a relation, there may be a primary key or may not, but there may 2M
be a key or combination of keys which uniquely identify the record. each
Such a key is called as Candidate key.
Primary key:
A key which is selected by the designer to uniquely identify the entity
is called as Primary key. A primary key cannot contain duplicate
values and it can never contain null values inside it.
(f) Explain concurrent execution of multiple transaction in detail. 4M
Ans. A transaction is a collection of operations that perform modifications
in database application.
A set of transactions can be executed by some sequence which is
called as a schedule.
There are two types of schedules as serial executions and concurrent Explana
execution. tion
When two transactions are executed one after the other, it is called as 4M
serial execution and when they are interleaved, it is called as
concurrent execution of transaction.
Concurrent execution should always preserve consistency. This
means that even if the transactions are interleaved, there should not
be any damage to data.
Example :
Transaction T1 :Rs. 50 of A’s account are transferred to B’s Account.
Transaction T2 : 10% of A’s balance is transferred to B’s Account
Consider initial amount as A=100, B=150 so initially A+B=150
Concurrent schedule will appear as :
Page 21 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
T1 T2
Read(A); ……A=100
A:=A-50;
Write(A); …..A=50
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); …..B=150
B:=B+50;
Write(B); …...B=200
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205
Diagra
m
Optiona
l
Computer networking allows some task to be executed on a server
system and some tasks on client system. This leads to development of
client server architecture. The clients are the machines which requests
for the service to the server. Server is the machine which serves to the
Page 22 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
clients.
There are different types of client/server architecture such as
• Two tier architecture,
• Three tier architecture.
In two tier architecture, client systems directly approach database
servers whereas in three tier architecture, there exists a middle layer
which acts as application server to receive and send requests from
client machine to database server and vice versa
(b) Explain Third normal form.
Ans. 3NF (Third normal form)
1) After removing all transitive dependencies and making
separate relations, relations get into 3NF.
2) Transitive dependency is can be stated as, let R be relation
and A, B and C be the set of attributes then, they are transitive
dependent if C depends on B, B depends on A and therefore C
depends on A. 4M
Example
Student_Detail Table :
Student_id Student_name DOB Street city State Zip Explana
tion 3M
In this table Student_id is Primary key, but street, city and state
depends upon Zip. The dependency between zip and other fields is
called transitive dependency. Hence to apply 3NF, we need to move
the street, city and state to new table, with Zip as primary key.
New Student_Detail Table : Exampl
e 1M
Student_id Student_name DOB Zip
Address Table :
Zip Street city State
Page 23 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Diagra
m 2M
Page 24 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Correct
use of
symbols
2M
Correct
entities
and
relation
ships
2M
Page 25 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Read(B); …..B=150
B:=B+50;
Write(B);
…...B=200
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205
T1 T2
Read(A);
……A=100
A:=A-50;
Write(A); …..A=50
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); …..B=150
B:=B+50;
Write(B);
…...B=200
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205
Page 26 / 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332
Explicit Locking:
The technique of lock taken on a table or its resources by a user is
called Explicit Locking. Explana
Users can lock tables they own or any tables on which they have been tion 4M
granted table privileges (such as select, insert, update, delete).
Explicit locking done by two ways as
Syntax:
LOCK TABLE <TableName> [, <TableName>]…
IN { ROW SHARE| ROW EXCLUSIVE|SHARE
UPDATE|SHARE|SHARE ROW EXCLUSIVE|EXCLUSIVE}
[NOWAIT]
Page 27 / 27