2018 Winter Model Answer Paper
2018 Winter Model Answer Paper
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER– 18 EXAMINATION
Subject Name: Database Management System Model Answer Subject Code: 22319
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values
may vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer
based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent
concept.
4. Integrity problems
5. Atomicity problems
It has 3 levels :
Page 1 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a. Physical level
b. logical level
c. view level
2. Data redundancy :
It may lead to data inconsistency, that is different copies of the same data may
have different values.
i) Candidate key
ii) ii) Primary key
Ans Candidate key: In a relation, there may be a primary key or may not, but there may be a 1 mark
key or combination of keys which uniquely identify the record. Such a key is called Candidate key
as Candidate key. 1 mark
Primary Key
OR
A candidate key is a column, or set of columns, in a table that can uniquely identify any
database record without referring to any other data.
The candidate key can be simple (having only one attribute) or composite as well.
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.
2. Drop
Page 2 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Syntax: drop table <table_name>;
3. Desc
OR
Desc <table_name>
4. Truncate
5. Alter
1. 1NF
2. 2NF
3. 3NF
4. BCNF
MAX()
MIN()
COUNT()
Page 3 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Cursor: The Oracle Engine uses a work area for its internal processing in order to 1 mark Cursor
execute an SQL statement. This work area is private to SQL‟s operations and is called a definition and
Cursor. 1 mark for
types of
OR cursor
A cursor is a temporary work area created in the system memory when a SQL statement
is executed.
1) Implicit cursor
2) Explicit cursor
Ans Set operators combine the results of two component queries into a single result. Queries 1 mark for
containing set operators are called as compound queries. Set operators in SQL are explanation
represented with following special keywords as: Union, Union all, intersection & minus. and 1 mark
for example
Consider data from two tables emp and employee as
each
Page 4 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Emp Employee
Ename
Ename
a
c
b
e
c
1) Union: The Union of two or more sets contains all elements, which are present in
either or both. Union works as or.
E.g. select ename from emp union select ename from employee;
Output
Ename
2) Union all: The Union of 2 or more sets contains all elements, which are present in
both, including duplicates.
E.g. select ename from emp union all select ename from employee;
Output
Page 5 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ename
Output
Ename
4) Minus: The minus of two sets includes elements from set1 minus elements of set2.
E.g. select ename from emp minus select ename from employee;
Ename
Page 6 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Output: rajesh
ii) Upper(char)-
Output: RAJESH
iii) Ltrim(char,set)-
Output: ersity
iv) Rtrim(char,set)-
Output: univer
v) Length(char)-
vi) Concat(str1,str2,...)-
Output: employeename
Returns the string str, left-padded with the string padstr to a length of len characters.
Example: Select lpad(ename,10.’*’) from emp where empno=7782;
viii) Rpad(str,len,padstr)-
Returns the string str, right-padded with the string padstr to a length of len characters.
Page 7 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
viii) Substr(Char,m,n)-
Output: lleg
Ans Exception Handling: Exception is nothing but an error. Exception can be raise when any relevant 4
DBMS encounters errors or it can be raised explicitly. points 1 mark
each
When the system throws a warning or has an error it can lead to an exception. Such
exception needs to be handled and can be defined internally or user defined.
Exception handling is nothing but a code block in memory that will attempt to resolve
current error condition.
Syntax:
DECLARE ;
Declaration section
…executable statement;
EXCEPTION
END;
Types of Exception:
2) User defined exception: It must be declare by the user in the declaration part of the
block where the exception is used. It is raised explicitly in sequence of statements using:
Raise_application_error(Exception_Number, Error_Message);
Page 8 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Commit: Description
and syntax –
The COMMIT command saves all transactions to the database since the last COMMIT 1 Mark
or ROLLBACK command example 1
Mark for each
The syntax: SQL> COMMIT;
Or
COMMIT WORK;
Example :
SQL>Commit;
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.
ROLLBACK TO SAVEPOINT_NAME;
OR
ROLLBACK;
OR
ROLLBACK WORK;
Example:
SQL>ROLLBACK;
A join which is based on equalities is called equi join. In equi join comparison
operator “=” is used to perform a Join.
Page 9 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Syntax:
SELECT tablename.column1_name,tablename.column1_name
FROM table_name1,table_name2
where table_name1.column_name=table_name2.column_name;
Example:
Where Stud_info.branch_code=branch_details.branch_code;
2) SELF JOIN:
The SQL SELF JOIN is used to join a table to itself, as if the table were two
tables, temporarily renaming at least one table in the SQL statement.
Syntax:
Example:
A left outer join retains all of the rows of the “left” table, regardless of whether there is a
row that matches on the “right” table.
Syntax:
Select column1name,column2name
on any_alias1.columnname(+) = any_alias2.columnname;
OR
Page 10 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Select column1name,column2name
on table1name.columnname= table2name.columnname;
Example:
on e.department_id(+) = d.department_id;
OR
on employees.department_id = departments.department_id;
A right outer join retains all of the rows of the “right” table, regardless of
whether there is a row that matches on the “left” table.
Syntax:
OR
on any_alias1.columnname =any_alias2.columnname;
Example:
OR
Page 11 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Select last_name, department_name
on e.department_id = d.department_id;
Non equi joins is used to return result from two or more tables where exact join is
not possible.
Syntax:
For example:
In emp table and salgrade table. The salgrade table contains grade and their low
salary and high salary. Suppose you want to find the grade of employees based on
their salaries then you can use NON EQUI join.
Syntax:
Page 12 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Where,
Example:
RETURN number
IS cnt number(7) := 0;
BEGIN
RETURN cnt;
END;
1. For prevention of data theft such as bank account numbers, credit card
information, passwords, work related documents or sheets, etc.
3. To provide confidentiality which ensures that only those individuals should ever
Page 13 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
be able to view data they are not entitled to.
4. To provide integrity which ensures that only authorized individuals should ever
be able change or modify information.
5. To provide availability which ensure that the data or system itself is available for
use when authorized user wants it.
7. To provide non-repudiation which deals with the ability to verify that message
has been sent and received by an authorized user.
OR
2. Integrity: when the contents of the message are changed after the sender sends
it, but before it reaches the intended recipient, we say that the integrity of the
message is lost.
4. Availability: The goal of availability s to ensure that the data, or the system
itself, is available for use when the authorized user wants it.
Ans 1. Schema Definition The Database Administrator creates the database schema by 1 Mark for
executing DDL statements. Schema includes the logical structure of database table each role
(Relation) like data types of attributes, length of attributes, integrity constraints etc.
2. Storage structure and access method definition The DBA creates appropriate
storage structures and access methods by writing a set of definitions which is translated
by data storage and DDL compiler.
Page 14 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
4. Granting authorization for data access The DBA provides different access rights to
the users according to their level. Ordinary users might have highly restricted access to
data, while you go up in the hierarchy to the administrator, you will get more access
rights. Integrity constraints specifications: Integrity constraints are written by DBA and
they are stored in a special file which is accessed by database manager while updating
data.
(iv) Ensure that performance is not degraded by some expensive task submitted by some
users.
6. Integrity- constraint specification: Integrity constraints are written by DBA and they
are stored in a special file, which is accessed by database manager, while updating the
data.
OR
A table is in the first normal form if it contains no repeating elements groups. Example:
Supplier(sno,sname,location,pno,qty)
The above relation is in 1NF as all the domains are having atomic value. But it is not in
2NF.
A relation is said to be in the second normal form if it is in first normal form and all the
non key attributes are fully functionally dependent on the primary key.
Page 15 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example:
In the above relation NAME, LOCATION depends on SNO and QTY on (SNO, PNO)
so the table can be split up into two tables as Supplier(SNO,SNAME,LOCATION) and
SP(SNO,PNO,QTY) and now both the tables are in second normal form.
Supplier
S1 Abc Mumbai
S2 Pqr Pune
S3 Lmn Delhi
Supplier_Product
S1 P1 200
S2 P2 300
S3 P1 400
Exception (Optional)
End; (Mandatory)
Page 16 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Advantages of PL/SQL:
3. It allows user to write as well as access the functions and procedures from outside the
programs.
d Write step by step syntax to create, open and close cursor in PL/SQL. 4M
Ans A cursor holds the rows (one or more) returned by a SQL statement. 2 marks,
Opening: 1
Declaring: This term is used to declare a cursor so that memory initialization will take mark, Closing
place. cursor: 1
mark
A cursor is declared by defining the SQL statement that returns a result set.
Example:
Opening: A Cursor is opened and populates data by executing the SQL statement
defined by the cursor.
Example:
Open Winter_18;
Closing a Cursor: This forces cursor for releasing the allocated memory assigned/
occupied by cursor.
Example:
CLOSE Winter_18;
Page 17 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
needs to take place in isolation. It helps in reducing complications of executing multiple
transactions at a time and preserves the consistency of the database.
3. Isolation: It is necessary to maintain isolation for the transactions. This means one
transaction should not be aware of another transaction getting executed. Also their
intermediate result should be kept hidden.
a Draw an E-R diagram of library management system considering issue and return, 6M
fine calculation facility, also show primary key, weak entity and strong entity.
Ans Correct
entities: 2M,
correct
symbols: 2M,
Correct
relationships:
2M
Ans i) Display the emp_id of employee who live in city ‘Pune’ or ‘Nagpur’ Each query :
2M
select emp_id
from Employee
Page 18 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
where emp_city=’Pune’ or emp_city=’Nagpur’
update Employee
set emp_name=’Ayan’
where emp_name=’Ayush’
Select count(*)
from Employee
where emp_dept=50;
c Consider the following schema Depositor (ACC_no, Name, PAN, Balance). Create a 6M
view on Depositor having attributes(ACC_No,PAN) where balance is greater than
100000
select ACC_No,PAN
from Depositor
a Create a sequence 6M
ii) Use a seq_1 to insert the values into table Student( ID Number(10), Name char
(20));
Ans i) create sequence Seq_1 start with 1 increment by 1 minvalue 1 maxvalue Query 1: 2M,
20; Query 2: 2M,
Query 3 : 1M,
ii) insert into student values(Seq_1.nextval,’ABC’); Query 4 : 1M
Page 19 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
iii) Alter sequence Seq_1 maxvalue 50;
b Write a PL/SQL program which accepts the customer_ID from the user. If the 6M
enters an invalid ID then the exception invalid_id is raised using exception
handling.
1) assuming table Employee for granting permissions to user ‘Rahul’ for select,
insert, update and delete privilege)
2) for create and drop privilege which are system privileges not specific to any
object such as table
Page 20 of 20