Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
43 views73 pages

Nswers DMS

6f6r7f5dirodothf f7t 8yutp7g8pgdgdktyykfyfliglyf n iltidkycjvuglkuggtjsfuldyzuujlftsjaryzchmzfuhcjtslhckkxlhkstykx 6ru6fodi5sit Upf6dod6tdodo6dod66d6od F7fotdd Rxkhcyfl Ucktdiucl Fzhchcdyufgig8h Xkyfi4sy Jgskfujjjg 7uykdrstdkyflydkydkfuuclud6uuglyduhlchmcchclukyducufl5usdycckxyuulfugl
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)
43 views73 pages

Nswers DMS

6f6r7f5dirodothf f7t 8yutp7g8pgdgdktyykfyfliglyf n iltidkycjvuglkuggtjsfuldyzuujlftsjaryzchmzfuhcjtslhckkxlhkstykx 6ru6fodi5sit Upf6dod6tdodo6dod66d6od F7fotdd Rxkhcyfl Ucktdiucl Fzhchcdyufgig8h Xkyfi4sy Jgskfujjjg 7uykdrstdkyflydkydkfuuclud6uuglyduhlchmcchclukyducufl5usdycckxyuulfugl
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/ 73

Zeal Education Society’s

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

SECOND YEAR (SY)


DIPLOMA IN COMPUTER ENGINEERING
SCHEME: I SEMESTER: III

NAME OF SUBJECT: DATA BASE MANGEMENT SYSTEM


Subject Code: 22319

MSBTE QUESTION PAPERS & MODEL ANSWERS


1. MSBTE WINTER-18 EXAMINATION
2. MSBTE SUMMER-19 EXAMINATION
3. MSBTE WINTER-19 EXAMINATION

Page 1 of 10
*22319*
22319
11819
3 Hours / 70 Marks Seat No.
Instructions : (1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.

Marks

1. Attempt any five of the following : 10


a) List disadvantages of typical file processing system.
b) Define i) data abstraction, ii) data redundancy.
c) Define the term :
i) Candidate key
ii) Primary key
d) List four DDL commands with syntax.
e) Define normalization, list its types.
f) Enlist four aggregate functions.
g) Define cursor. List the two types of cursor.

2. Attempt any three of the following : 12


a) Distinguish between network model and hierarchical model (any 4 points).
b) Explain set operators with example.
c) Explain any four string functions with example.
d) Describe exception handling in brief.

3. Attempt any three of the following : 12


a) Describe commit and rollback with syntax and example.
b) Explain joins in SQL with examples.
c) Explain function in PL/SQL with example.
d) Explain database security with it’s requirements in detail.

P.T.O.
22319 *22319*
Marks
4. Attempt any three of the following : 12
a) Explain the four roles of database administrator.
b) State and explain 1NF and 2NF with example.
c) Draw the block structure of PL/SQL . List advantages of PL/SQL.
d) Write step by step syntax to create, open and close cursor in PL/SQL.
e) Explain transaction ACID properties.

5. Attempt any two of the following : 12


a) Draw an E-R diagram of library management system considering issue and return, fine
calculation facility, also show primary key, weak entity and strong entity.
b) Consider the following database Employee(emp_id, emp_name, emp_city, emp_addr,
emp_dept, join_date)
i) Display the emp_id, of employee who live in city ‘Pune’ or ‘Nagpur’.
ii) Change employee name, ‘Aayush’ to ‘Aayan’.
iii) Display the total number of employee whose dept is 50.
c) Consider the following schema Depositor (ACC_no, Name, PAN, Balance) Create a
view on Depositor having attributes (ACC_no, PAN) where balance is greater than 100000.

6. Attempt any two of the following : 12


a) Create a sequence
i) Sequence name is Seq _ 1, Start with 1, increment by 1, minimum value 1,
maximum value 20.
ii) Use a seq_1 to insert the values into table Student (ID Number (10), Name char (20));
iii) Change the seq_1 max value 20 to 50.
iv) Drop the sequence.
b) Write a PL/SQL program which accept the customer ID from the user if user enters an
invalid ID then the exception invalid_id is raised using exception handling.
c) i) Create user ‘Rahul’.
ii) Grant create, select, insert, update, delete, drop privilege to ‘Rahul’.
iii) Removes the select privilege from user ‘Rahul’.

––––––––––––––
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(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.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following : 10 M

a List disadvantages of typical file processing system. 2M

Ans Disadvantages of file processing system any 4


disadvantages
1. Data redundancy and inconsistency – 1/2 Mark
each
2. Difficulty in accessing data disadvantage
3. Data isolation

4. Integrity problems

5. Atomicity problems

b Define i)Data Abstraction ii)Data Redundancy 2M

Ans 1. Data Abstraction : 1 mark Data


Abstraction
Many end users are not computer trained so it is needed to hide complex data structures description 1
from them. mark Data
Hiding complexity of data structures from end user through different levels is known Redundancy
as data abstraction. description

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 :

The repetition of information is known as redundancy .This redundancy leads


to higher storage and access cost.

It may lead to data inconsistency, that is different copies of the same data may
have different values.

c Define the term: 2M

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.

For Example, {STUD_NO, COURSE_NO} is a composite candidate key for relation


STUDENT_COURSE.

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.

Example, RollNo attribute is a primary key for Relation Student.

d List Four DDL commands with syntax. 2M

Ans DDL commands 1/2 mark for


each
1. 1.Create command and
½ mark for
Syntax : create table <table_name>(Column_name1 datatype1, column_name2 syntax
Datatype2,…Column_nameN DatatypeN);

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

Syntax: describe <table_name>;

OR

Desc <table_name>

4. Truncate

Syntax: truncate table <table_name>;

5. Alter

Syntax: Alter table <table_name> add Column_name Datatype (size);

e Define Normalization, list its types. 2M

Ans Normalization: 1 mark for


Normalization
Normalization can be defined as process of decomposition/division of database tables to definition and
avoid the data redundancy. 1 mark for
types
Types of Normalization:

1. 1NF

2. 2NF

3. 3NF

4. BCNF

f Enlist four aggregate functions. 2M

Ans SUM() any 4


functions
AVG()

MAX()

MIN()

COUNT()

g Define Cursor. List the two types of cursor. 2M

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.

Types of cursor are:

1) Implicit cursor

2) Explicit cursor

2 Attempt any THREE of the following : 12 M

a Distinguish between network model and hierarchical model. 4M

Ans Sr. Hierarchical model Network model any 4 points


No.
1.
Hierarchical model is not more Network model is more popular than
popular than network model the hierarchical and relational model.
2.
It does not uses client server It uses client –server architecture
architecture
3.
One to many relationship is One to many and many to many
maintained. relationship is maintained.
4.
Hierarchical model is based on tree Network model is based on tree like
like structure with one root. structure with many roots.
5.
One child or many children have only Many children have many parent
one parent
6.
Main application of hierarchical It is upgraded version of hierarchical
model is in the mainframe database model so used in network
system.
b Explain set Operators with example. 4M

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;

The output considering above data is :

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;

The output considering above data is:

Output

Page 5 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Ename

d 3) Intersection: The intersection of two sets includes elements which are


present in both. E.g. select ename from emp intersect select ename from
e employee;

The output considering above data is:

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;

The output considering above data is:

Ename

c Explain any four String functions with example. 4M

Ans i) Lower(char)- 1 mark for


explanation
Returns the input string with all letters in lower case. and 1 mark
for example
Example: SQL>Select lower (‘RAJESH’) from dual; each

Page 6 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Output: rajesh

ii) Upper(char)-

Returns the input string with all letters in upper case.

Example: SQL>Select upper (‘rajesh’) from dual;

Output: RAJESH

iii) Ltrim(char,set)-

It removes or trims from left of character string

. Example: SQL>Select Ltrim(‘university’,’univ’) from dual;

Output: ersity

iv) Rtrim(char,set)-

It removes or trims from right of character string.

Example: SQL>Select Rtrim(‘university’,’sity’) from dual;

Output: univer

v) Length(char)-

It returns length of character string.

Example: SQL> Select length(‘University’) from dual; Output:10

vi) Concat(str1,str2,...)-

Returns the string that result from concatenating the arguments.

Example: Select Concat(‘employee’, ‘name’) from dual;

Output: employeename

vii) Lpad(str, len, padstr)-

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.

Example: Select rpad(ename,10.’*’) from emp where empno=7782;

Page 7 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
viii) Substr(Char,m,n)-

It returns a portion of char, beginning at a character m, n character long.

Example: Select substr(‘College’,3,4) from dual;

Output: lleg

d Describe exception handling in brief. 4M

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

WHEN ex_name1 THEN ;

Error handling statements/user defined action to be carried out;

END;

Types of Exception:

1) Predefined Exception/system defined exception/named exception: Are always


automatically raised whenever related error occurs. The most common errors that can
occur during the execution of PL/SQL. Not declared explicitly i.e. cursor already open,
invalid cursor, no data found, zero divide and too many rows etc. Programs are handled
by system defined Exceptions.

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);

3 Attempt any THREE of the following : 12 M

a Describe commit and rollback with syntax and example. 4M

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.

The syntax for ROLLBACK is:

ROLLBACK TO SAVEPOINT_NAME;

OR

ROLLBACK;

OR

ROLLBACK WORK;

Example:

SQL>ROLLBACK;

b Explain joins in SQL with examples. 4M

Ans JOIN: Definition: 2


marks, Any 2
A SQL join is an instruction to combine data from two sets of data (i.e. two tables). A types with
JOIN clause is used to combine rows from two or more tables, based on a related column description: 1
between them. SQL Join types are as follows: mark each

1) INNER JOIN or EQUI JOIN:

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:

Select stud_info.stud_name, stud_info.branch_code, branch_details.location

From stud_info, branch_details

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:

SELECT a.column_name, b.column_name

FROM table1 a, table1 b

WHERE a.common_filed = b.common_field;

Example:

Select x.stud_name, y.stud_name

from stud_info x, stud_info y

Where x.leader= y.stud_id;

3) LEFT OUTER JOIN:

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

from table1name any_alias1 ,table2name any_alias2

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

from table1name left outer join table2name

on table1name.columnname= table2name.columnname;

Example:

select last_name, department_name

from employees e, departments d

on e.department_id(+) = d.department_id;

OR

select last_name, department_name

from employees left outer join departments

on employees.department_id = departments.department_id;

4) RIGHT OUTER JOIN:

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:

Select column1name, column2name

from table1name any_alias1, table2name any_alias2

on any_alias1.columnname =any_alias2.columnname (+);

OR

Select column1name, column2name

from table1name any_alias1 right outer join table2 name any_alias2

on any_alias1.columnname =any_alias2.columnname;

Example:

Select last_name,department_name from employees e, departments d on


e.department_id = d.department_id(+);

OR

Page 11 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Select last_name, department_name

from employees e right outer join departments d

on e.department_id = d.department_id;

5) NON EQUI JOIN:

Non equi joins is used to return result from two or more tables where exact join is
not possible.

Syntax:

Select aliasname.column1name, aliasname.column2name from tablename alias


where <condition using range>;

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.

Select e.empno, e.ename, e.sal, s.grade

from emp e, salgrade s

where e.sal between s.lowsal and s.hisal;

c Explain function in PL/SQL with example. 4M

Ans Function: Description: 2


marks,
Function is a logically grouped set of SQL and Pl/SQL statements that perform a Example : 2
specific task. A function is same as a procedure except that it returns a value. A marks
function is created using the CREATE FUNCTION statement.

Syntax:

CREATE [OR REPLACE] FUNCTION function_name


[(parameter_name [IN | OUT | IN OUT] type [, ...])]
RETURN return_datatype
{IS | AS}
BEGIN
< function_body >
END [function_name];

Page 12 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Where,

 function-name specifies the name of the function.


 [OR REPLACE] option allows the modification of an existing function.
 The optional parameter list contains name, mode and types of the parameters. IN
represents the value that will be passed from outside and OUT represents the
parameter that will be used to return a value outside of the procedure.
 The function must contain a return statement.
 The RETURN clause specifies the data type you are going to return from the
function.
 function-body contains the executable part.
 The AS keyword is used instead of the IS keyword for creating a standalone
function.

Example:

CREATE OR REPLACE FUNCTION Success_cnt

RETURN number

IS cnt number(7) := 0;

BEGIN

SELECT count(*) into cnt

FROM candidate where result='Pass';

RETURN cnt;

END;

d Explain database security with its requirements in detail. 4M

Ans Database security Definition 1


Mark, 3 mark
Database security refers to the collective measures used to protect and secure a database for detail
or database management software from illegal use and malicious threats and attacks. description

Requirements of Database Security:

1. For prevention of data theft such as bank account numbers, credit card
information, passwords, work related documents or sheets, etc.

2. 2. To make data remain safe and confidential.

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.

6. To provide authentication which deals with the desire to ensure that an


authorized individual.

7. To provide non-repudiation which deals with the ability to verify that message
has been sent and received by an authorized user.

OR

1. Confidentiality: The principle of confidentiality specifies that only sender


and intended recipients should be able to access the contents of a message.
Confidentiality gets compromised if an unauthorized person is able to access the
contents of a message

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.

3. Authentication: Authentication helps to establish proof of identities. The


Authentication process ensures that the origin of a message is correctly identified.

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.

4 Attempt any THREE of the following : 12 M

a Explain the four roles of database administrator. 4M

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.

3. Schema and physical organization modification DBA writes set of definitions to


modify the database schema or description of physical storage organization.

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.

5. Routine Maintenance some of the routine maintenance activities of a DBA is


given below.

(i) Taking backup of database periodically

(ii) Ensuring enough disk space is available all the time.

(iii) Monitoring jobs running on the database.

(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.

b State and Explain 1 NF and 2 NF with example. 4M

Ans First Normal Form (1NF): For 1NF - 2


Marks, For
A relation R is said to be in first normal form (1NF) if the domain of all attributes of R 2NF -2 Marks
are atomic.

OR

A table is in the first normal form if it contains no repeating elements groups. Example:
Supplier(sno,sname,location,pno,qty)

SNO SNAME LOCATION PNO QTY

S1 Abc Mumbai P1 200

S2 Pqr Pune P2 300

S3 Lmn Delhi P1 400

The above relation is in 1NF as all the domains are having atomic value. But it is not in
2NF.

Second Normal Form (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

SNO SNAME LOCATION

S1 Abc Mumbai

S2 Pqr Pune

S3 Lmn Delhi

Supplier_Product

SNO PNO QTY

S1 P1 200

S2 P2 300

S3 P1 400

c Draw the block structure of PL/SQL. List advantages of PL/SQL. 4M

Ans Declare (Optional) For block


structure - 2
--Use for declaring variables Marks, For
advantages -2
Marks
Begin (Mandatory)

--Use for writing executable code;

Exception (Optional)

--Use to write exceptions to be catch during run time.

End; (Mandatory)

--To terminate PL-SQL block/ code.

Page 16 of 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Advantages of PL/SQL:

1. PL/SQL is portable and high transaction processing language.

2. PL/SQL is in fact procedural language but it also supports object oriented


programming.

3. It allows user to write as well as access the functions and procedures from outside the
programs.

4. It has got built in libraries of packages.

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:

Declare CURSOR Winter_18 IS SELECT roll_no, std_name, percentage FROM


student;

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;

e Explain Transaction ACID properties. 4M

Ans ACID properties of transaction For each


property - 1
1. Atomicity: When one transaction takes place, many operations occur under one Mark
transaction. Atomicity means either all operations will take place property and reflect in
the database or none of them will be reflected.

2. Consistency: Consistency keeps the database consistent. Execution of a transaction

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.

4. Durability: When a transaction gets completed successfully, it is important that the


changes made by the transaction should be preserved in database in spite of system
failures.

5 Attempt any TWO of the following : 12 M

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

b Consider the following database 6M


Employee(emp_id,emp_name,emp_city,emp_addr,emp_dept,join_date)

i) Display the emp_id of employee who live in city ‘Pune’ or ‘Nagpur’.

ii) Change the employee name ‘Ayush’ to ‘Ayan’.

iii) Display the total number of employee whose dept is 50.

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’

ii) Change the employee name ‘Ayush’ to ‘Ayan’

update Employee

set emp_name=’Ayan’

where emp_name=’Ayush’

iii) Display the total number of employee whose dept is 50

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

Ans create view v1 Correct logic


3M, Correct
as syntax :3M

select ACC_No,PAN

from Depositor

where balance > 100000;

6 Attempt any TWO of the following : 12 M

a Create a sequence 6M

i) Sequence name is Seq_1, Start with 1, increment by 1, minimum value 1,


maximum value 20.

ii) Use a seq_1 to insert the values into table Student( ID Number(10), Name char
(20));

iii) Change the Seq_1 max value 20 to 50.

iv) Drop the sequence.

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;

iv) Drop sequence Seq_1;

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.

Ans DECLARE Correct logic :


c_id numeric(10); 3M, Correct
invalid_id_Exception Exception; syntax : 3M
BEGIN
c_id:=&c_id;
if(c_id<0) then
raise invalid_id_Exception;
end if;
EXCEPTION
WHEN invalid_id_Exception THEN
dbms_output.put_line('Invalid customer id');
END;

c i) create user ‘Rahul’ 6M

ii) grant create, select,insert,update, delete, drop privilege to ‘Rahul’

iii) Remove the select privilege from user ‘Rahul’

Ans (i) create user Rahul identified by rahul1234; each query :


2M
(ii)

1) assuming table Employee for granting permissions to user ‘Rahul’ for select,
insert, update and delete privilege)

Grant select, insert,update,delete on employee to Rahul;

2) for create and drop privilege which are system privileges not specific to any
object such as table

Grant connect, resource, DBA to Rahul;

iii) (assuming table Employee for revoking permissions to user ‘Rahul’)

Revoke select on Employee from Rahul;

Page 20 of 20
21819
22319
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.

(2) Illustrate your answers with neat sketches wherever necessary.

(3) Figures to the right indicate full marks.

(4) Assume suitable data, if necessary.

Marks
1. Attempt any FIVE of the following : 10
(a) Define :
(i) Instance (ii) Schema
(b) List any four advantages of DBMS.
(c) State any two E.F. Codd’s rule for RDBMS.
(d) List DCL commands.
(e) Define Normalization and list its types.
(f) Write syntax for creating synonyms with example.
(g) State any four PL/SQL datatypes.

2. Attempt any THREE of the following : 12


(a) Explain overall structure of DBMS with the help of diagram.
(b) Explain difference between delete and truncate command with example.
(c) Write and explain syntax for creating view with example.
(d) Explain PL/SQL block structure with the help of diagram.

[1 of 4] P.T.O.
22319 [2 of 4]
3. Attempt any THREE of the following : 12
(a) State and explain 2NF with example.
(b) Explain any four aggregate functions with example.
(c) Explain exception handling in PL/SQL with example.
(d) Explain state of transaction with the help of diagram.

4. Attempt any THREE of the following : 12


(a) State the difference between Relational and Hierarchical model.
(b) List the SQL operations and explain range searching operation ‘between’ and
pattern matching operator ‘like’ with example.
(c) Explain cursor with example.
(d) State the use of database trigger and also list types of trigger.
(e) Explain recovery techniques with example.

5. Attempt any TWO of the following : 12


(a) Draw ER diagram for library management system considering issue and
return, fine collection facility. Consider appropriate entities.
(b) Consider the table
Student (name, marks, dept, age, place, phone, birthdate) Write SQL query for
following :
(i) To list students having place as ‘Pune’ or ‘Jalgaon’.
(ii) To list students having same department (dept) as that of ‘Rachana’.
(iii) To change marks of ‘Rahul’ from 81 to 96.
(iv) To list student name and marks from ‘Computer’ dept.
(v) To list student name who have marks less than 40.
(vi) To list students who are not from ‘Mumbai’.
(c) Create simple and composite index. Write command to drop above index.
22319 [3 of 4]
6. Attempt any TWO of the following : 12

(a) (i) Write a command to create table student (RNo., name, marks, dept.)
with proper datatype and RNo as primary key.

(ii) Write a command to create and drop sequence.

(b) Write a PL/SQL program to calculate factorial of a given number.

(c) Write SQL command for following :

(i) Create user

(ii) Grant privileges to user

(iii) Remove privileges from user

_______________

P.T.O.
22319 [4 of 4]
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

SUMMER – 19 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.

Q. Sub Answer Marking


No. Q. Scheme
N.
1. Attempt any FIVE of the following: 10 M
a Define : 2M
(i) Instance (ii) Schema
Ans (i) Instance: The data stored in database at a particular moment 1 M for each
of time is called instance of database. Definition
(ii) Schema: Design of a database is called the schema. Schema
is of three types: Physical schema, logical schema and view
schema.
b List any four advantages of DBMS. 2M
Ans  Controlling Redundancy ( ½ M for any
 Maintaining Integrity advantage)
 Inconsistency can be avoided
 Data can be shared
 Restricting unauthorized access
 Providing Backup and Recovery
 Concurrency Control
 Better security.
c State any two E.F. Codd’s rule for RDBMS. 2M
Ans 1. The Information rule: All information in an RDBMS is represented ½ M for each
logically in just one way - by values in tables. rule , ½ M each
Page No:1 /21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

2. The Guaranteed Access rule: Each item of data in an RDBMS is proper


guaranteed to be logically accessible by resorting to a combination of statement
table name, primary key value, and column name.
3. The Systematic Treatment of Null Values rule: Null values
(distinct from an empty character string or a string of blank characters
and distinct from zero or any other number) are supported in a fully
relational DBMS for representing missing
4. The Dynamic Online Catalog Based on the Relational Model rule:
The database description is represented at the logical level in the same
way as ordinary data, so that authorized users can apply the same
relational database.
5. The Comprehensive Data Sublanguage rule: A relational system
may support several languages and various modes of terminal for data
definition, view definition, data manipulation etc.
6. The View Updating rule: All views of the data which are
theoretically updatable must be updatable in practice by the DBMS.
7. The High-level Insert, Update, and Delete rule: The capability of
handling a base relation or a derived relation as a single database to
perform all DML operations.
8. The Physical Data Independence rule: Application programs and
terminal activities remain logically unchanged whenever any changes
are made in either storage representations or access methods.
9. The Logical Data Independence rule: Application programs and
terminal activities remain logically unchanged when information
preserving changes of any kind are made to the base tables.
10. The Integrity Independence rule: Integrity constraints must be
definable in the RDBMS sub-language and stored in the system
catalogue and not within individual application programs.
11. The Distribution Independence rule: An RDBMS has distribution
independence. Distribution independence implies that users should not
have to be aware of whether a database is distributed.
12. The No subversion rule: If the database has any means of handling
a single record at a time that low-level language must not be able avoid
the integrity rules which are expressed in a higher-level language that
handles multiple records at a time.
d List DCL commands. 2M
Ans DCL is Data Control Language: 1 M for each
command
1. GRANT

2. REVOKE
e Define Normalization and list its types. 2M
Ans Normalization is a process of organizing the data in database to avoid 1 M for
data redundancy, insertion anomaly, update anomaly & deletion definition, 1 M
anomaly. for the types

Page No:2 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Types of normalization are :

 First normal form(1NF)


 Second normal form(2NF)
 Third normal form(3NF)
 Boyce & Codd normal form (BCNF)
 Fourth normal form(4NF)

f Write syntax for creating synonyms with example 2M


Ans 1 M for correct
Syntax to create synonym: syntax, 1 M for
CREATE SYNONYM SYNONYM_name correct
FOR Table_name; example

Example to create synonym:


CREATE SYNONYM offices
FOR locations;

g State any four PL/SQL data types. 2M


Ans 1. NUMBER or NUMBER(P,S) ½ M for each
2. PLS_INTEGER data type
3. CHAR
4. RAW
5. ROWID
6. VARCHAR2
7. DATE

2 Attempt any THREE of the following: 12 M


a Explain overall structure of DBMS with the help of diagram. 4M
Ans Components of DBMS structure are classified in 3 categories as: 2 M for correct
1. Query processor : diagram, 2 M
Embedded DML pre compiler: It converts DML statements embedded for correct
in application. explanation
Program to normal procedural calls in host language.
DML Compiler: It translates DML statements of high level language
into low level instruction that a query evaluation engine understands.
DDL interpreter: It interprets DDL statements and records them in a
set of tables containing metadata.
Query evaluation Engine: It executes low level instructions generated
by DML compiler and issued by query processor to select efficient ways
to execute query.
DDL interpreter. It has following components,

Page No:3 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

2. Storage Manager Components :


Transaction manager: It ensures that the database remains in
consistent state despite of the system failure and that concurrent
transaction execution proceeds without conflicting.
File Manager: It manages the allocation of space on disk storage and
data structures used to represent information stored on disk
Buffer Manager: It is responsible for fetching data from disk storage
into main memory and deciding what data to cache memory.
3. Disk storage :
Data files: It stores the database.
Data Dictionary: It stores metadata that hold particular values.
Indices: Provide fast access to data items that hold particular values.
Statistical data: It stores statistical information about the data in the
database.

b Explain difference between delete and truncate command with 4M


example.
Ans DELETE Command :
 It is DML (Data Manipulation Language) command.

Page No:4 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

 It is used to remove all or specific records of table. (2 M for proper


 WHERE clause can be used to remove specific records. explanation of
 Syntax: each
DELETE FROM Table_name; command) or
OR (any 4
DELETE FROM Table_name differences)
WHERE Condition;

 Example:
DELETE FROM Employees
WHERE Emp_id=100;
 ROLLBACK command can be used to get deleted record.

TRUNCATE Command :
 It is a DDL( Data Definition Language) command
 It is used to remove all records permanently.
 WHERE clause can be used as it removes all records.
 Syntax:
TRUNCATE TABLE Table_name;
 Example:
TRUNCATE TABLE Employees;
 ROLLBACK command cannot be used to get records.
 New records can be added into a table as structure remains
intact.

OR

Page No:5 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DELETE TRUNCATE
It is DML(Data It is a DDL( Data
Manipulation Language) Definition Language)
command command
It is used to remove all or It is used to remove all
specific records of table. records permanently.
WHERE clause can be used WHERE clause can be
to remove specific records. used as it removes all
records.

Syntax: DELETE FROM Syntax: TRUNCATE


Table_name; TABLE Table_name;
OR
DELETE FROM
Table_name
WHERE Condition;

Example: DELETE FROM Example: TRUNCATE


Employees TABLE Employees;
WHERE Emp_id=100;
ROLLBACK command can ROLLBACK command
be used to get deleted cannot be used to get
record. records. New records can
be added into a table as
structure remains intact.

c Write and explain syntax for creating view with example. 4M


Ans A view contains rows and columns, just like a real table. The fields in a 2 M for correct
view are fields from one or more real tables in the database. syntax, 1 M for
explanation,
View has two types: 1 M for correct
example
1. Simple view: The fields in a view are fields from one table in the
database.

2. Complex view: The fields in a view are fields from more than one
table in the database. You can add SQL functions, WHERE, and JOIN
statements to a view and present the data as if the data were coming
from different table.

CREATE VIEW Syntax


Create view view_name As

Page No:6 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Select column1, column2…


From table_name
Where condition ;

Example
Create view mumbai_customers AS
Select customer_name,contact_name
From customers
Where city=’Mumbai’;

d Explain PL/SQL block structure with the help of diagram. 4M


Ans. PL/SQL Block Strucure : PL/SQL block
structure 2M,
Explanation
2M

Explanation of PL/SQL Block Strucure:

Declaration section

A block begins with declarative section where variables, cursors


are declared. It is an Optional block.

Execution section

Executable SQL or PL/SQL Statements are needed to write here

Page No:7 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

for the execution. It is mandatory block.

Exception section
It is used to handles the exceptions. It is an Optional block.

End statement
It is used to indicate termination of PL/SQL block. It is mandatory.

3 Attempt any THREE of the following: 12 M


a State and explain 2NF with example. 4M
Ans A table is said to be in 2NF if both the following conditions hold: State : 1M
Explanation
 Table is in 1NF (First normal form) with example:
 No non-prime attribute is dependent on the proper subset of any 3M
candidate key of table.
 San attribute that is not part of any candidate key is known as
non-prime attribute.
 Example: Suppose a school wants to store the data of teachers
and the subjects they teach. They create a table that looks like
this: Since a teacher can teach more than one subjects, the table
can have multiple rows for a same teacher.

teacher_id Subject teacher_age

111 Math’s 38

111 Physics 38

222 Biology 38

333 Physics 40

333 Chemistry 40

CandidateKeys:{teacher_id,subject}

Non-prime attribute: teacher_age The table is in 1 NF because each


attribute has atomic values. However, it is not in 2NF because non-
prime attribute teacher_age is dependent on teacher_id alone which is a
proper subset of candidate key. This violates the rule for 2NF as the rule
says “no non-prime attribute is dependent on the proper subset of any
candidate key of the table “To make the table complies with 2NF we
can break it in two tables like this:
teacher details tab

Page No:8 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

teacher_id teacher_age

111 38

222 40

333 40

teacher_subject Table:

Teacher_id Subject
111 Math’s

111 Physics

222 Biology

333 Physics

333 Chemistry

b Explain any four aggregate functions with example. 4M


Ans An aggregate function is a function where the values of multiple rows Any 4
are grouped together as input on certain criteria to form a single value of aggregate
more significant meaning. functions with
example : 1M
Aggregate functions are : each
1) Count()
2) Sum()
3) Avg()
4) Min()
5) Max()

1. Count () - 1) It returns number of rows from the given table if no


attribute is mentioned.
2) If some attribute is mentioned, it gives total number of not null values

Page No:9 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

for that attribute.


Eg :Select count(*) from emp;
Returns total number of records from emp table.
1) Select count(telephone) from emp;
Returns total number of employees having telephone numbers.
2. Sum() - It give total of all values from a numeric attribute of the
given table,
Eg :Select sum(salary) from emp;
Returns total salary drawn of all employees from the emp table.
3. Avg () - It gives average of all the numeric values of the given
attribute from the table.
Eg :Select Avg(salary) from emp;
Returns average salary of employees from emp table.
4. Min () - It gives minimum of all the values of the numeric given
attribute from the table.
Eg :Select Min(salary) from emp;
Returns minimum salary value from emp table,
5. Max () - It gives maximum of all the values of the numeric given
attribute from the table.
Eg :Select Max(salary) from emp;
retunes maximum salary value from emp table,

c Explain exception handling in PL/SQL with example. 4M


Ans Exception handling in PL/SQL: Explanation :
2M ,
An exception is an error condition during a program execution. PL/SQL example :2M
supports programmers to catch such conditions using EXCEPTION
block in the program and an appropriate action is taken against the error
condition.

There are two types of exceptions −

 System-defined (built in) exceptions

Page No:10 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

 User-defined exceptions

The general syntax for exception handling is as follows :

DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling goes here >
WHEN exception1 THEN
exception1-handling-statements
WHEN exception2 THEN
exception2-handling-statements
……
….….
END;

Raising Exceptions

Exceptions are raised by the database server automatically whenever


there is any internal database error, but exceptions can be raised
explicitly by the programmer by using the command RAISE. Following
is the simple syntax for raising an exception

DECLARE
exception_name EXCEPTION; BEGIN
IF condition THEN
RAISE exception_name;
END IF;
EXCEPTION
WHEN exception_name THEN
statement;
END;
You can use the above syntax in raising the Oracle standard exception
or any user-defined exception.
Example :
DECLARE
A number:=20;
B number:=0;
C number;
BEGIN
dbms_output.put_line(‘First Num : ’||A);
dbms_output.put_line(‘Second Num : ’||B);

Page No:11 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

C:= A / B;
--Raise built in Exception if B is 0
dbms_output.put_line(‘ Result ’ || C);-- and then Result will not
be displayed
EXCEPTION
WHEN ZERO_DIVIDE THEN
dbms_output.put_line(‘ Trying to Divide by zero :: Error ’);
END;

d Explain states of transaction with the help of diagram. 4M

Ans diagram : 1M,


explanation :
3M

Active –the initial state; the transaction stays in this state while it is
executing
Partially committed –after the final statement has been executed.
Failed - after the discovery that normal execution can no longer
proceed.
Aborted – after the transaction has been rolled back and the database
restored to its state prior to the start of the transaction. Two options after
it has been aborted: restart the transaction - can be done only if no
internal logical error kill the transaction Committed –after successful
completion.

4 Attempt any THREE of the following: 12 M


a State difference between relational and hierarchical model. 4M
Ans Relational model Hierarchical model. Any 4
A database model to manage data A structure of data organized in differences :
as tuples grouped into a tree like model using parent 1M each
relations(tables) child relationships.

Arranges data in tables Arranges data in tree like


structure

Page No:12 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Represents both “one to many” Represents “one to many”


and”many to many” relationships. relationship

Easier to access data Difficult to access data

Flexible Less flexible

Example : Example :

b List the SQL operations and explain range searching operations 4M


between and pattern matching operator ‘like’ with example.

Ans Types of SQL operators : List of


operators : 2M,
1) SQL Arithmetic Operators between
2) SQL Comparison Operators operator : 1M,
Like operator :
3) SQL Logical Operators 1M
Arithmetic operators are used to perform arithmetic operations on
numbers. They are +,-,*, / and %.
Comparison operators are used in between two variables to compare
their values. They are <,>,<=,>=,=,!=or <>,!< and !>.'
Logical operators are used for the Boolean results in sql queries for
comparison of values from the attributes of the tables. Eg: Any, Exists,
All, Like, Between, In etc.
Between operator: The BETWEEN operator is used to search for
values that are within a set of values, given the minimum value and the
maximum value inclusive of both the limits.
Eg: select * from emp where salary between 40000 and 50000;
This will results in rows from emp table where salary falls in the range
of 40000 to 50000.

Page No:13 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Like operator :
The LIKE operator is used to compare a value to similar values using
wildcard operators. It uses two wild characters as ‘%’ and ‘_’ where ‘%’
represents all characters of the pattern and ‘_’ represents one single
character from pattern.
Eg :
Select ename from emp where ename like ‘S%’;
This will return all employee names starting with ‘S’.
Select ename from emp where ename like ‘_a%;
This will return all employee names whose second character is ‘a’.

c Explain cursor with example. 4M

Ans A cursor is a temporary work area created in system memory when a Explanation :
SQL statement is executed. A cursor is a set of rows together with a 2M, example :
pointer that identifies a current row. It is a database object to retrieve 2M
data from a result set one row at a time. It is useful when we want to
manipulate the record of a table in a singleton method, in other words
one row at a time. In other words, a cursor can hold more than one row,
but can process only one row at a time. The set of rows the cursor holds
is called the active set.
Each cursor contains the followings 4 steps,

1. Declare Cursor: In this part we declare variables and return a set


of values.
2. Open: This is the entering part of the cursor.
3. Fetch: Used to retrieve the data row by row from a cursor.
4. Close: This is an exit part of the cursor and used to close a
cursor.
5. Eg:

Declare
enumemp.eno%type;
enemp.ename%type;
Cursor cur is select eno, ename from emp where jobname = “mgr”;
Begin

Page No:14 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Open cur;
Loop Fetch cur into enum,en;
Exit when cur%NOTFOUND;
Dbms_output.put_line(„emp num ‟||enum||‟ emp name „||en);
End loop;
Close cur;
End; /
The example shows fetching multiple records using cursor. A cursor is
a temporary work area created in system memory when a SQL
statement is executed. A cursor is a set of rows together with a pointer
that identifies a current row.
In the example, the cursor is defined to hold the rows as defined by the
select query. Once the cursor is defined, the next step is to open the
cursor. When the cursor is opened, it is ready to retrieve the rows. This
is done using the fetch statement. Since there are many rows, a loop is
used to display the values of all the rows. Once the rows are fetched, the
cursor should be closed.

d State the use of database trigger and also list types of trigger. 4M

Ans Use of trigger Use : 3M List


of types : 1M
Trigger: A trigger is a stored procedure in database which automatically
invokes whenever a special event in the database occurs. A trigger can
be invoked when a row is inserted into a specified table or when certain
table columns are being updated.
Triggers are written to be executed in response to any of the following
events −
A database manipulation (DML) statement (DELETE, INSERT, or
UPDATE)
Database definition (DDL) statements (CREATE, ALTER, or DROP).
A database operation (SERVERERROR, LOGON, LOGOFF,
STARTUP, or SHUTDOWN).
Triggers can be defined on the table, view, schema, or database with
which the event is associated.

Page No:15 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Triggers can be written for the following purposes –


 Generating some derived column values automatically
 Enforcing referential integrity
 Event logging and storing information on table access
 Auditing
 Synchronous replication of tables
 Imposing security authorizations
 Preventing invalid transactions
Types of trigger

 DML Triggers
 DDL Triggers
 Logon Triggers

e Explain recovery techniques with example. 4M


Ans When recovering the database, it is must redo the effects of the previous Explanation :
transactions. This is called Rolling Forward or simple Forward 3M,
Recovery. Not all but some active transaction that didn’t complete Example 1M
successfully needs to rollback, when the disk drive crashed. Such kind
of rollback is called Backward Recovery.

The Redo Log and Rolling Forward (REDO operation)


The redo log is a set of operating system files that record all changes
made to any database buffer, including data, index, and rollback
segments, whether the changes are committed or uncommitted. The redo
log protects changes made to database buffers in memory that have not
been written to the data files.
The first step of recovery from an instance or disk failure is to roll
forward, or reapply all of the changes recorded in the redo log to the
data files. Because rollback data is also recorded in the redo log, rolling
forward also regenerates the corresponding rollback segments.

Rolling forward proceeds through as many redo log files as necessary to


bring the database forward in time. Rolling forward usually includes
online redo log files and may include archived redo log files.

After roll forward, the data blocks contain all committed changes as

Page No:16 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

well as any uncommitted changes that were recorded in the redo log.

Rollback Segments and Rolling Back (UNDO operation)


Rollback segments record database actions that should be undone during
certain database operations. In database recovery, rollback segments
undo the effects of uncommitted transactions previously applied by the
rolling forward phase. After the roll forward, any changes that were not
committed must be undone. After redo log files have reapplied all
changes made to the database, then the corresponding rollback segments
are used. Rollback segments are used to identify and undo transactions
that were never committed, yet were recorded in the redo log and
applied to the database during roll forward. This process is called rolling
back.

(Descriptive example can be considered)

5 Attempt any TWO of the following: 12 M


a Draw an E-R diagram of library management system considering 6M
issue and return,
Fine calculation facility. Consider appropriate entities.

Page No:17 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Correct
entities: 2M,

correct
symbols: 2M,

Correct
relationships:
2M

b Consider the table 6M


Student (name, marks, dept, age, place, phone, birthdate). Write
SQL query for following.
i)To list students having place as ‘Pune’ or ‘Jalgaon’
ii)To list students having same department(dept) as that of
‘Rachana’
iii) To change marks of ‘Rahul’ from 81 to 96.
iv) To list student name and marks from ‘Computer’ dept.
v) To list student name who have marks less than 40.
vi)To list students who are not from ‘Mumbai;
Ans select name from Student where place= ‘Pune’ or place=’Jalgaon’; Each Correct
(OR) Query : 1M
select name from Students where place in(‘Pune’,‘Jalgaon’);
ii)select name from Student where dept=(select dept from student where
name=’Rachana’);
iii)update Student set marks=96 where name= ‘Rahul’;
v)select name,marks from Student where dept=‘Computer’;
iv)select name from Student where marks<40;
v)select * from Student where place != ‘Mumbai’;
c Create simple and composite index. Write command to drop above 6M
index.
Ans Create simple index Simple index
Syntax: Create index index_name on <tablename><column name>; 2M,
(OR)
Composite

Page No:18 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

E.g.: Create index idx_empno on employee (empno); index: 2M


Create composite index:
Syntax: Create index index_name on <tablename><Column_name1, Drop index 2M
Column_name2>;
(Note: Either
(OR) syntax or
E.g.: Create index idx_ename_eno on employee (ename, empno);
example can be
considered.
Drop Index:
Syntax: Drop index <index_name>; Any other
(OR) example
E.g. (Assuming idx_empno created on employee table) allowed.)
Drop index idx_empno;

6 Attempt any TWO of the following: 12 M


a i) Write a command to create table student(RNO,name marks,
dept) with proper datatypes and RNo as primary key 6M
ii) Write a command to create and drop sequence.
Ans i) create table student Correct query:
( 3M
RNO number(5) constraint student_RNO_pk primary key,
name varchar2(20), Create
marks number(4), sequence : 2M
dept varchar2(20)
Drop sequence
);
:1M
(OR)
create table student (Note: For (ii)
( Either syntax
RNO number(5) , or example can
name varchar2(20), be considered.
marks number(4),
dept varchar2(20), Any other
constraint student_RNO_pk primary key(RNO), example
); allowed)

ii) Create Sequence:


Create sequence <seq_name>
Start with [initial value]
Increment by [value]
Minvalue [minimum value]
Maxvalue [maximum value]
[cycle/no cycle]
[{cache value / No cache}]
[{order / No order}];

Page No:19 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

(OR)

(Creating sequence for Employee number of emp table.)

Create sequence emp_eno_seq


start with 1
increment by 1
maxvalue 100
no cycle
no cache;

Drop sequence:

Drop sequence<Sequence Name>;


(OR)
Drop sequence emp_eno_seq;
b Write a PL/SQL program to calculate factorial of a given number. 6M

Ans DECLARE Correct


num number:=&num; Syntax:
fact number:=1; 3M,Correct
BEGIN logic : 3M

while num!=0 (Note: Any


loop other logic can
fact:=fact*num; be considered)
num:=num-1
end loop;
dbms_output.put_line(‘Factorial =’||fact);
END;
/
(OR)
DECLARE
num number:=&num;
fact number:=1;
i number;
BEGIN
for i in 1..num loop
fact:=fact*i;
end loop;

Page No:20 /21


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

dbms_output.put_line('Factorial='||fact);
END; /

c Write SQL command for following 6M


i)Create user
ii) Grant privileges to user.
Iii) Remove privileges from user.

Ans i)Create user Each correct


command: 2M
CREATE USER <username> IDENTIFIED BY <password>;
(Note: Either
(OR)
syntax or
CREATE USER RAJ IDENTIFIED BY RAJ123; example can be
considered.
ii) Grant privileges to user. Any other
GRANT <privilege list> ON <relation name or view name> example
TO<user list>; allowed)

(OR)
(assuming table Employee for granting permissions to user ‘RAJ’
for select, insert, update and delete privilege)
GRANT SELECT, INSERT,UPDATE,DELETE ON
EMPLOYEE TO RAJ;

Iii) Remove privileges from user.


REVOKE <privilege list> ON <relation name or view name >
FROM <user list>;

(OR)
(assuming table Employee for revoking permissions to user ‘RAJ)
REVOKE SELECT, INSERT,UPDATE,DELETE ON
EMPLOYEE FROM RAJ;

Page No:21 /21


11920
22319
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.


(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.
(5) Mobile Phone, Pager and any other Electronic Communication
devices are not permissible in Examination Hall.

Marks

1. Attempt any FIVE of the following : 10

(a) State any two advantages of DBMS over file processing system.

(b) Draw three level architecture of DBMS.

(c) Define table and field.

(d) Enlist DML commands.

(e) Define primary key and foreign key.

(f) List any four string functions in SQL.

(g) State any two advantages of functions in PL/SQL.

2. Attempt any THREE of the following : 12

(a) Distinguish between Network and Hierarchical model. (Any four points)

(b) Explain any four set operators in SQL with example.

(c) Describe Views and write a command to create view.

(d) Explain implicit and explicit cursors.

[1 of 4] P.T.O.
22319 [2 of 4]
3. Attempt any THREE of the following : 12

(a) State and explain 3NF with example.

(b) Define index. Explain it’s types.

(c) Explain Exception handling with it’s types.

(d) Explain ACID properties of traction.

4. Attempt any THREE of the following : 12

(a) Explain strong and weak entity set.

(b) Describe create & alter command with syntax & example.

(c) Define database trigger. How to create and delete trigger ?

(d) Explain any one control structure in PL/SQL with example.

(e) Describe database backups with it’s types.

5. Attempt any TWO of the following : 12

(a) Draw an ER diagram for library management system. (Use Books, Publisher
& Member entities).

(b) Write a command to create table student (rollno, Stud_name, branch, class,
DOB, City, Contact_no) and write down queries for following :

(i) Insert one row into the table

(ii) Save the data

(iii) Insert second row into the table

(iv) Undo the insertion of second row

(v) Create save point S1.

(vi) Insert one row into the table.


22319 [3 of 4]
(c) Consider following schema :
EMP (empno, deptno, ename, salary, designation, join_date, DOB,
dept_location). Write down SQL queries for following :
(i) Display employees name & number in decreasing order of salary.
(ii) Display employee name & employee number whose designation is
Manager.
(iii) Display age of employees with ename.
(iv) Display total salary of all employees.
(v) Display employee names having deptno as 20 and dept_location is
Mumbai.
(vi) Display name of employee who earned lowest salary.

6. Attempt any TWO of the following : 12


(a) Consider the structure for book table as Book-Master (bookid, bookname,
author, no_of copies, price)
Write down SQL queries for following
(i) Write a command to create Book_master table.
(ii) Get authorwise list of all books.
(iii) Display all books whose price is between ` 500 & ` 800.
(iv) Display all books with details whose name start with ‘D’.
(v) Display all books whose price is above ` 700.
(vi) Display all books whose number of copies are less than 10.
(b) Write a PL/SQL program to print n even numbers using For Loop.
(c) Describe database privileges. Write down the procedure for granting &
revoking privileges in database objects to the users.
_______________

P.T.O.
22319 [4 of 4]
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System 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.

Q. Sub Answer Marking


No Q.N. Scheme
.
1. Attempt any FIVE of the following: 10
(a) State any two advantages of DBMS over file processing system. 2M
Ans. Advantages of DBMS over file processing system:
 Reduction in Data redundancy
 Data consistency and integrity
 Data security Any two
 Privacy advanta
 Easy access of data ges 1M
 Easy recovery each
 Flexibility
(b) Draw three level architecture of DBMS. 2M
Ans.

Page 1 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

Correct
diagram
2M

(c) Define table and field. 2M


Ans. Table: A table is a collection of related data held in table format. It is
a set of data elements using a model of vertical columns and Each
horizontal rows. definitio
Field: Each table contains field which is a data structure, used to hold n 1M
the data. It can also be termed as attribute.
(d) Enlist DML commands. 2M
Ans.  Insert - used to insert new row into table Any 2
 Delete- used to delete a row from the table comman
 Update – used to modify data in the table. ds 1M
 Select – used to view data from a table. each
(e) Define primary key and foreign key. 2M
Ans. Primary key is an attribute or set of attributes used to identify an
entity from an entity set. All the values of a primary key should be Each
unique and null values are not allowed. definitio
Foreign key is an attribute of an entity which is the primary key of n 1M
another entity. It is used to show relation between entities. The table
containing foreign key is called the child table.
(f) List any four string functions in SQL. 2M
Ans. Initcap(String) – converts first character of string to upper case
Upper(String) – converts the string to upper case Any
Lower(String) – converts string to lower case four
Length(String) – returns the number of characters in the string string
Instr(String, sub) – returns the location of the substring function
Lpad(String,char,number) – returns the string left padded with the s ½M
character specified to a total of length specified. each
Rpad(String,char,number) – returns the string right padded with the

Page 2 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

character specified to a total of length specified.


Ltrim(String) -removes white space or other specified characters from
the left end of the string
Rtrim(String)--removes white space or other specified characters
from the right end of the string
Replace(String, char,char) – replace all occurrence of a substring by
another substring
Substring(String,number) – extracts substring from the string
Translate(String,char,char) – replace all occurrence of characters by
other characters
(g) State any two advantages of functions in PL/SQL. 2M
Ans. Advantages of functions in PL/SQL:
 Work can be divided into smaller modules so that it can be
manageable and also enhances the readability of the code. Any two
 It promotes reusability. advanta
 It is secure, as the code is in the database and hides the internal ges 1M
database details from the user. each
 It improves performance against running SQL queries multiple
times.
2. Attempt any THREE of the following: 12
(a) Distinguish between Network and Hierarchical model. (Any four 4M
points)
Ans. Sr. Network Model Hierarchical model
No.
1 Represents tree like Represents tree like structure
structure with many roots with one root
2 Reflects M:N(many to Reflects 1:N (one-to-
many) relations many)relations Any
3 Allows a child to have There can be only one parent four
more than one parent node points
4 Relationship is represented Relationships between 1M each
as pointers or links records is of parent-child
type
5 This model is free from There are multiple
such inconsistency as there occurrence of child records
is only a single occurrence and therefore inconsistency
of a record set.
6 Searching a record is easy Searching a record is
as there are multiple paths difficult as a child can be

Page 3 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

to a data element. reached only through a


parent
(b) Explain any four set operators in SQL with example. 4M
Ans. Set operators combine the results of two component queries into a
single result. Queries containing set operators are called as compound
queries. Set operators in SQL are represented with following special
keywords as: Union, Union all, intersection & minus.
1) Union: The Union of two or more sets contains all elements, 1M each
which are present in either or both. Union works as or. The duplicates for
of both the tables will appear only once. explanat
E.g. select ename from emp1 union select ename from emp2; ion of
2) Union all: The Union of 2 or more sets contains all elements, operator
which are present in both, including duplicates. s with
E.g. select ename from emp1 union all select ename from emp2; example
3) Intersection: The intersection of two sets includes elements which
are present in both.
E.g. select ename from emp1 intersect select ename from emp2;
4) Minus: The minus of two sets includes elements from set1 minus
elements of set2.
E.g. select ename from emp1 minus select ename from emp2;
(c) Describe Views and write a command to create view. 4M
Ans. A view is a virtual table based on the result set of the SQL statement.
The fields in a view are fields from one or more than one table in the
database. SQL functions, where, join statements can be added to a
view and the data in it can be presented as if it were from one table.
The database engine recreates the data, using the view’s SQL
statement, every time a user queries a view. A view can be updated Explana
using the create or replace view command. For deleting a view, drop tion 3M
query can be used.

General syntax to create a view:


create view viewname as select query. General
Eg: syntax/
create view vw_student as select stud_id, stud_name,ssc_per from example
student; 1M
(d) Explain implicit and explicit cursors. 4M
Ans. A cursor is a temporary work area created in system memory when an
SQL statement is executed. A cursor is a set of rows together with a
pointer that identifies a current row. It is a database object to retrieve

Page 4 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

data from result set on row at a time.


Implicit cursor: these types of cursors are generated and used by the
system during the manipulation of a DML query. An implicit cursor Each
is also generated by the system when a single row is selected by a explanat
SELECT command. ion 2M
Programmers cannot control the implicit cursors.
Explicit cursor: this type of cursor is created by the user when the
select command returns more than one row, and only one row is to be
processed at a time. An explicit cursor can move from one row to
another in a result set. An explicit cursor uses a pointer that holds the
record of a row.
To create an explicit cursor the following steps are used.
1. Declare cursor: this is done in the declaration section of PL/SQL
program.
2. Open: this step is done before the cursor is used to fetch the
records.
3. Fetch: used to retrieve data row by row from the cursor.
4. Close: once the processing of the data is done, the cursor can be
closed.
3. Attempt any THREE of the following: 12
(a) State and explain 3NF with example. 4M
Ans. 3NF:
An entity is said to be in the third normal form when,
1) It satisfies the criteria to be in the second normal form.
2) There exists no transitive functional dependency. (Transitive Explana
functional dependency can be explained with the relationship link tion 2M
between three tables. If table A is functionally dependent on B, and B
is functionally dependent on C then C is transitively dependent on A).
Let us consider the Schema given:
(Supplier_no,SupplierName,Supplier_city,Order_no,Order_quantity,
Order_amount,Product_code,Product name,rate)
Step 1.To convert it into 2NF, We have to decompose the given table
Any
into two tables with fully functional dependencies and establishing a
example
referential integrity constraint relationship among the two tables.
2M
Table2: Supplier Details
(Supplier_no,Supplier_name,Supplier_city)
Table 3:Order Details
(Order_no,Order_ quantity,Order_amount,Supplier_no Product_code,

Page 5 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

product_name,rate)
Now the above two tables are in 2NF
Step 2: To convert the above tables in 3NF, we have to
decomposehem in three tables satisfying the transitive dependencies
property.
Table 4: Supplier Details
(Supplier_no,Supplier_name,Supplier_city)
Table 5: Product Details:
(Product_code, product_name,rate)
Table 6: Order Details (or Transaction Details)
((Order_no,Supplier_no,Product_code,Order_quantity,Order_amount
)
Hence the above three tables are satisfying Transitive dependencies.
Thus they are in 3NF.
(b) Define index. Explain it‟s types. 4M
Ans. An Index is a schema object. It is used by the oracle server to
improve the speed of retrieval of the rows from a table .Indexes are of Definitio
two types based on number of columns included in the index. n 1M
The types of index are:
1) Simple index: An index created on a single column of table is
called as simple index
Syntax: Each
SQL>Create Index index_name on tablename(attribute); type
Example:Create index emp_index on emp(empno); 1½M
2) Composite Index: An index created on more than one column is
called composite index.
Syntax:
SQL>Create Index index_name on
tablename(attribute1,attribute2);
Example: Create index emp_index on emp(empno,ename);
(c) Explain Exception handling with it‟s types. 4M
Ans. An exception is an error condition during a program execution.
PL/SQL supports programmers to catch such conditions Explana
using EXCEPTION block in the program and an appropriate action tion 2M
is taken against the error condition.
There are two types of exceptions −
 1) System-defined exceptions/Predefined exceptions/Built-in
exceptions

Page 6 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

 2) User-defined exception
1) Predefined exceptions- PL/SQL provides predefined Exception,
which are executed when any database rule is violated by a program.
Example: NO_DATA_FOUND, ZERO_DIVIDE.
Syntax for Predefined Exception Handling:
Types
The general syntax for exception handling is as follows. 2M
DECLARE
<declarations section>
BEGIN
<executable command(s)>
EXCEPTION
<exception handling goes here >
WHEN exception1 THEN
exception1-handling-statements
WHEN exception2 THEN
exception2-handling-statements
WHEN exception3 THEN
exception3-handling-statements
........
WHEN others THEN
exception3-handling-statements
END;
2) User defined Exceptions:
PL/SQL allow us to define our own exception according to the need
of our program. A user defined exception must be declared and then
raised explicitly.

Syntax for User defined Exception:


DECLARE
exception_name EXCEPTION;
BEGIN
IF condition THEN
RAISE exception_name;
END IF;
EXCEPTION
WHEN exception_name THEN
statement;
END;

Page 7 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

(d) Explain ACID properties of traction. 4M


Ans. A transaction can be defined as a group of tasks. A single task is the
minimum processing unit which cannot be divided further.

ACID Properties
A transaction is a very small unit of a program and it may contain
several lowlevel tasks. A transaction in a database system must Explana
maintain Atomicity, Consistency, Isolation, and Durability − tion
commonly known as ACID properties − in order to ensure accuracy, of each
completeness, and data integrity. property
1M
 Atomicity: This property states that a transaction must be treated
as an atomic unit, that is, either all of its operations are executed
or none. There must be no state in a database where a transaction
is left partially completed. States should be defined either before
the execution of the transaction or after the
execution/abortion/failure of the transaction.
 Consistency: The database must remain in a consistent state after
any transaction. No transaction should have any adverse effect on
the data residing in the database. If the database was in a
consistent state before the execution of a transaction, it must
remain consistent after the execution of the transaction as well.
 Isolation: In a database system where more than one transaction
are being executed simultaneously and in parallel, the property of
isolation states that all the transactions will be carried out and
executed as if it is the only transaction in the system. No
transaction will affect the existence of any other transaction.
 Durability: The database should be durable enough to hold all its
latest updates even if the system fails or restarts. If a transaction
updates a chunk of data in a database and commits, then the
database will hold the modified data. If a transaction commits but
the system fails before the data could be written on to the disk,
then that data will be updated once the system springs back into
action.
4. Attempt any THREE of the following: 12
(a) Explain strong and weak entity set. 4M
Ans. Strong entity set:
An entity set that has sufficient attributes to form a primary key is

Page 8 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

called as Strong entity set.


Example: Employee is a Strong entity with attributes as empid, name,
address, salary, birthdate among which empid can be considered as
primary key.

Weak entity set: Each


The entity set which does not have sufficient attributes to form a entity set
primary key is called as Weak entity set. 2M
A weak entity is an entity that cannot be uniquely identified by its
attributes alone; therefore, it must use a foreign key in conjunction
with its attributes to create a primary key. The foreign key is typically
a primary key of an entity it is related to.
Example: Employee has "dependents" with name, birthdate, and
relationship to employee and it can be related to employee with the
help of empid, so "dependents" is a weak entity which depends on
strong entity "Employee".
(b) Describe create & alter command with syntax & example. 4M
Ans. 1) The SQL CREATE TABLE statement is used to create a new
table.

Syntax
The basic syntax of the CREATE TABLE statement is as follows –
CREATE TABLE table_name Each
comman
(
d 2M
column1 datatype (size),
column2 datatype(size),
column3 datatype(size),
....
);
Example:
CREATE TABLE Persons
(
PersonIDnumber(10),
LastNamevarchar2(20),
FirstNamevarchar2(20),
Address varchar2(20),
City varchar2(20)

Page 9 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

);

2)The ALTER TABLE statement is used to add, delete, or modify


columns in an existing table.

The ALTER TABLE statement is also used to add and drop various
constraints on an existing table.

i) To add Columns in a table


Syntax:ALTER TABLE table_name
ADD column_name datatype;
Example
ALTER TABLE Customers
ADD Email varchar2(20);
ii) To delete a column in a table
ALTER TABLE table_name
DROP COLUMN column_name;
Example
ALTER TABLE Customers
DROP COLUMN Email;
iii) To modify a column in a table
Syntax:
ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
Example
ALTER TABLE Customers
MODIFY COLUMN customeridnumeric(10);
iv) To add Constraints in A table
Syntax:
ALTER TABLE table_name
ADD constraint constraintname (column_name);
Example:
ALTER TABLE Customers
ADD constraint primary key(CustomerID);

Page 10 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

(c) Define database trigger. How to create and delete trigger? 4M


Ans. Triggers are stored programs, which are automatically executed or
fired when some events occur. Triggers are, in fact, written to be Definitio
executed in response to any of the following events − n 1M
 A database manipulation (DML) statement (DELETE,
INSERT, or UPDATE)
 A database definition (DDL) statement (CREATE, ALTER, or
DROP).
Triggers can be defined on the table, view, schema, or database with
which the event is associated.

Creating Triggers
The syntax for creating a trigger is −
CREATE [OR REPLACE ] TRIGGER trigger_name
{BEFORE | AFTER | INSTEAD OF } Create
{INSERT [OR] | UPDATE [OR] | DELETE} 2M
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;

To delete a trigger: Delete


Syntax: 1M
DROP TRIGGER trigger_name.
(d) Explain any one control structure in PL/SQL with example. 4M
Ans. PL/SQL has three categories of control statements: conditional
selection statements, loop statements and sequential control
statements.
PL/SQL categories of control statements are:
 Conditional selection statements, which run different statements
for different data values.

Page 11 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

The conditional selection statements are IF and CASE.


 Loop statements, which run the same statements with a series of
different data values.
Explana
The loop statements are the basic LOOP, FOR LOOP, tion of
and WHILE LOOP. Any one
control
The EXIT statement transfers control to the end of a loop. structur
The CONTINUE statement exits the current iteration of a loop and e 4M
transfers control to the next iteration.
Both EXIT and CONTINUE have an optional WHEN clause, where
you can specify a condition.

 Sequential control statements, which are not crucial to PL/SQL


programming.

The sequential control statements are GOTO, which goes to a


specified statement, and NULL, which does nothing.

1)Conditional Control: IF and CASE Statements:


The IF statement lets us execute a sequence of statements
conditionally. That is, whether the sequence is executed or not
depends on the value of a condition. There are three forms
of IF statements: IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSIF.
The CASE statement is a compact way to evaluate a single condition
and choose between many alternative actions.

IF-THEN Statement:The simplest form of IF statement associates a


condition with a sequence of statements enclosed by the
keywords THEN and END IF (not ENDIF), as follows:
IF condition THEN
sequence_of_statements
END IF;

IF-THEN-ELSE Statement: The second form of IF statement adds


the keyword ELSE followed by an alternative sequence of statements,
as follows:
IF condition THEN
sequence_of_statements1
Page 12 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

ELSE
sequence_of_statements2
END IF;

IF-THEN-ELSIF Statement: The third form of IF statement uses


the keyword ELSIF (not ELSEIF) to introduce additional conditions,
as follows:
IF condition1 THEN
sequence_of_statements1
ELSIF condition2 THEN
sequence_of_statements2
ELSE
sequence_of_statements3
END IF;

CASE Statement: Like the IF statement, the CASE statement selects


one sequence of statements to execute.
IF grade = 'A' THEN
dbms_output.put_line('Excellent');
ELSIF grade = 'B' THEN
dbms_output.put_line('Very Good');
ELSIF grade = 'C' THEN
dbms_output.put_line('Good');
ELSIF grade = 'D' THEN
dbms_output. put_line('Fair');
ELSIF grade = 'F' THEN
dbms_output.put_line('Poor');
ELSE
dbms_output.put_line('No such grade');
END IF;

END CASE;

2) Iterative Control: LOOP and EXIT Statements:


LOOP statements let us execute a sequence of statements multiple
times. There are three forms of LOOP statements: LOOP, WHILE-
LOOP, and FOR-LOOP.

LOOP: The simplest form of LOOP statement is the basic (or

Page 13 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

infinite) loop, which encloses a sequence of statements between the


keywords LOOP and END LOOP, as follows:
LOOP
sequence_of_statements
END LOOP;

WHILE-LOOP:The WHILE-LOOP statement associates a condition


with a sequence of statements enclosed by the
keywords LOOP and END LOOP, as follows:
WHILE condition LOOP
sequence_of_statements
END LOOP;

Before each iteration of the loop, the condition is evaluated. If the


condition is true, the sequence of statements is executed, then control
resumes at the top of the loop. If the condition is false or null, the
loop is bypassed and control passes to the next statement.

FOR-LOOP:Whereas the number of iterations through


a WHILE loop is unknown until the loop completes, the number of
iterations through a FOR loop is known before the loop is
entered. FOR loops iterate over a specified range of integers. The
range is part of an iteration scheme, which is enclosed by the
keywords FOR and LOOP. A double dot (..) serves as the range
operator. The syntax follows:
FOR counter IN [REVERSE] lower_bound..higher_bound LOOP
sequence_of_statements
END LOOP

3)Sequential Control: GOTO and NULL Statements: Unlike


the IF and LOOP statements, the GOTO and NULL statements
are not crucial to PL/SQL programming.

GOTO Statement

The GOTO statement branches to a label unconditionally.


BEGIN
...
GOTO insert_row;
Page 14 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

...
<<insert_row>>
INSERT INTO empVALUES ...
END;
(e) Describe database backups with it‟s types. 4M
Ans. Regular backups are required to protect database and
ensure its restoration in case of failure. Various backup types provide Descript
different protection to our database. Backing up and restoring data is ion 2M
one of the most important responsibilities of IT professionals
Three common types of database backups can be run on a desired
system: normal (full), incremental and differential.
i) Normal or Full Backups:
When a normal or full backup runs on a selected drive, all the files on
that drive are backed up. This, of course, includes system files,
application files, user data — everything. Those files are then copied
to the selected destination (backup tapes, a secondary drive or the Types
cloud), and all the archive bits are then cleared. 2M

Normal backups are the fastest source to restore lost data because all
the data on a drive is saved in one location.
ii) Incremental Backups:
A common way to deal with the long running times required for
full backups is to run them only on weekends. Many businesses then
run incremental backups throughout the week since they take far less
time. An incremental backup will grab only the files that have been
updated since the last normal backup. Once the incremental
backup has run, that file will not be backed up again unless it changes
or during the next full backup.

iii) Differential Backups:


An alternative to incremental database backups that has a less
complicated restore process is a differential backup. Differential
backups and recovery are similar to incremental in that these backups
grab only files that have been updated since the last normal backup.
However, differential backups do not clear the archive bit. So a file

Page 15 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

that is updated after a normal backup will be archived every time a


differential backup is run until the next normal backup runs and clears
the archive bit.
5. Attempt any TWO of the following: 12
(a) Draw an ER diagram for library management system. (Use 6M
Books, Publisher & Member entities).
(Note: Consider any relevant diagram)
Ans.

Correct
entities
2M

Correct
symbols
2M

Correct
relations
hips 2M

(b) Write a command to crate table student (rollno, Stud_name, 6M


branch, class, DOB, City, Contact_no) and write down queries
for following:
(i) Insert one row into the table
(ii) Save the data
(iii) Insert second row into the table
(iv) Undo the insertion of second row
(v) Create save point S1.
(vi) Insert one row into the table.
Ans.

Page 16 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

SQL>Create table student(


Rollno number(5),
Stud_name char(10, Create
branch varchar(10), table 3M
class varchar(10),
DOB date,
city varchar(15),
Contact_no number(12)
);

(i) Insert one row into the table:


SQL>Insert into student values(1,‟Ram‟,‟CO‟,‟FirstYear‟,‟12-
jun-2001‟,‟Pune‟,98576867)
Each
(ii) Save the data: correct
SQL> commit; Query
( OR ) ½M
SQL> commit work; each

(iii)Insert second row into the table:


SQL>Insert into student values(2,‟Raj‟,‟CO‟,‟FirstYear‟,‟22-Sep-
2002‟,‟Mumbai‟,98896863)

(iv)Undo the insertion of second row:


SQL> rollback;
( OR)
SQL> rollback work;

(v)Create savepoint s1:


SQL>Savepoint s1;

(vi) insert one row into the table:


SQL>Insert into student values(3,‟Beena‟,‟CO‟,‟FirstYear‟,‟30-
Dec-2002‟,‟Mumbai‟,97846455)
(c) Consider following schema: 6M
EMP (empno, deptno, ename, salary, designation, join_date,
DOB, dept_location). Write down SQL queries for following:
(i) Display employees name & number in decreasing order of
salary.

Page 17 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

(ii) Display employee name & employee number whose


designation is Manager.
(iii) Display age of employees with ename.
(iv) Display total salary of all employees.
(v) Display employee names having deptno as 20 and
dept_location is Mumbai
(vi) Display name of employee who earned lowest salary.
Ans.
(i)Display employees name &number in descending order of salary:
SQL> select ename,empno from EMP order by salary desc;

(ii) Display employee name & employee number whose designation


is Manager. Each
SQL> select ename,empno from EMP where correct
designation=‟Manager‟; Query
1M
(iii) Display age of employees with ename
SQL>select round ( (sysdate - DOB ) /365, 0 ) as “age”,ename
from EMP;
OR
select months_between(TRUNC(sysdate),DOB)/12 as “age”
,ename from EMP ;
(**Note consider any other logic also)

(iv)Display total salary of all employees.


SQL> select sum(salary) from EMP;

(v)Display employee names having deptno as 20 and dept_location is


Mumbai.
SQL> select enamefrom EMP where deptno=20 and
dept_location=‟Mumbai‟;

(vi)Display name of employee who earned lowest salary


SQL> select ename from EMP where salary=(select min(salary)
from EMP);
6. Attempt any TWO of the following: 12
(a) Consider the structure for book table as Book-Master (bookid, 6M
bookname, author, no_of copies, price)
Write down SQL queries for following:

Page 18 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

(i) Write a command to create Book_master table.


(ii) Get authorwise list of all books.
(iii) Display all books whose price is between 500 & 800.
(iv) Display all books with details whose name start with „D‟.
(v) Display all books whose price is above 700.
(vi) Display all books whose number of copies are less than 10.
Ans.
(i)Write a command to create Book_Master table table.
SQL>Create table Book-Master(
bookid number(5),
bookname char(10),
authorvarchar(20), Each
no_of_copiesnumber(10), correct
price number(10,2) Query
); 1M

(ii)Get authorwise list of all books.


SQL>Select sum(no_of copies) from Book_Master group by
author;

(iii)Display all books whose price is between Rs.500 & Rs. 800
SQL> Select * from Book_Master where price between 500 and
800;
OR
SQL> Select * from Book_Master where price >=500 and
price<=800;

(iv) Display all books with details whose name start with ‘D’
SQL> Select bookname from Book_Master where bookname like
„D%‟;

(v)Display all books whose price is above Rs. 700


SQL>Select * from Book_Master where price >700;

(vi) Display all books whose number of copies are less than 10
SQL>Select * from Book_Master where no_of_copies<10;
(b) Write a PL/SQL program to print n even numbers using For 6M
Loop.
(Note: Any other logic can be allowed)

Page 19 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

Ans. declare
num number; Correct
n number:=&n; logic 3M
begin
for num in 1..n loop
if(mod(num,2)=0) then
dbms_output.put_line(‘Even no are :’||num); Correct
end if; syntax
end loop; 3M
end;
(c) Describe database privileges. Write down the procedure for 6M
granting & revoking privileges in database objects to the users.
Ans. Database privileges:
When multiple users can access database objects, authorization can
be controlled to these objects with privileges. Every object has an
owner. Privileges control if a user can modify an object owned by Databas
another user. Privileges are granted or revoked either by the instance e
administrator, a user with the ADMIN privilege or, for privileges to a Privilege
certain object, by the owner of the object. s 2M
1) System Privileges:
System privileges are privileges given to users to allow them to
perform certain functions that deal with managing the database and
the server
e.gCreate user, Create table, Drop table etc.

2) Object Privileges:
Object privileges are privileges given to users as rights and
restrictions to change contents of database object – where database
objects are things like tables, stored procedures, indexes, etc.
Ex. Select,insert,delete,update,execute,references etc
Procdure for granting privileges
Grant: This command is used to give permission to user to do Procedu
operations on the other user’s object. re for
Syntax: Grant<object privileges>on<object granting
name>to<username>[with grant option] ; privilege
Example: Grant select, update on emp to user1; s
2M
Procedure for revoking privileges
Revoke: This command is used to withdraw the privileges that has

Page 20 / 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

WINTER – 2019 EXAMINATION


MODEL ANSWER
Subject: Database Management System Subject Code: 22319

been granted to a user. Procedu


Syntax: Revoke <object privileges>on<object name>from re for
<username> ; revoking
Example: Revoke select, update on emp from user1; privilege
s 2M

Page 21 / 21

You might also like