0% found this document useful (0 votes)
3K views20 pages

2018 Winter Model Answer Paper

The document provides instructions to examiners for evaluating answers to a Database Management System exam. It lists 7 important instructions, including examining answers based on key words rather than word-for-word, allowing for variation in figures drawn, and allowing for different but equivalent programs for programming questions. It then provides a sample exam with one question that has 7 sub-questions requiring definitions, descriptions, and lists of database concepts and commands.

Uploaded by

Kill Bill
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)
3K views20 pages

2018 Winter Model Answer Paper

The document provides instructions to examiners for evaluating answers to a Database Management System exam. It lists 7 important instructions, including examining answers based on key words rather than word-for-word, allowing for variation in figures drawn, and allowing for different but equivalent programs for programming questions. It then provides a sample exam with one question that has 7 sub-questions requiring definitions, descriptions, and lists of database concepts and commands.

Uploaded by

Kill Bill
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/ 20

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

You might also like