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