1120231-CO - DBMS All Board Papers With Answers
1120231-CO - DBMS All Board Papers With Answers
OUR SERVICES:
Diploma in All Branches, All Subjects
Degree in All Branches, All Subjects
BSCIT / CS
Professional Courses
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
V2V EDTECH LLP
Online Coaching at an Affordable Price.
OUR SERVICES:
Diploma in All Branches, All Subjects
Degree in All Branches, All Subjects
BSCIT / CS
Professional Courses
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;
OUR SERVICES:
Diploma in All Branches, All Subjects
Degree in All Branches, All Subjects
BSCIT / CS
Professional Courses
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
V2V EDTECH LLP
Online Coaching at an Affordable Price.
OUR SERVICES:
Diploma in All Branches, All Subjects
Degree in All Branches, All Subjects
BSCIT / CS
Professional Courses
a) Define 2M
i) Data Abstraction
ii) Instance.
Ans i) Data Abstraction: Each correct
Hiding complexity of data structures from end user through different levels is known definition: 1M
as data abstraction.
Many end users are not computer trained so it is needed to hide complex data
structures from them.
It has 3 levels :
a. Physical level
b. logical level
c. view level
ii) Instance:
The data stored in database at a particular moment of time is called instance of
database.
Example:
Let’s say a table teacher in our database whose name is School, suppose the table has
50 records so the instance of the database has 50 records for now and tomorrow we
are going to add another fifty records so tomorrow the instance have total 100 records.
This is called an instance.
Page No: 1 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) State any two advantages of DBMS. 2M
Ans Normalization is a process of organizing the data in database to avoid data 1 M for correct
redundancy, insertion anomaly, update anomaly & deletion anomaly. definition, 1 M
for correct types
Types of normalization are:
• First normal form(1NF)
• Second normal form(2NF)
• Third normal form(3NF)
• Boyce & Codd normal form (BCNF)
Page No: 2 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Subtraction Operator (-) operators: 1M
Multiplication Operator (+)
Division Operator (-)
Modulus Operator (+)
AND operator
OR operator
BETWEEN operator
IN operator
NOT operator
ANY operator
LIKE operator
Page No: 3 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
2. Attempt any THREE of the following: 12 M
Ans Explanation=3M
Diagram=1M
1. External level
It is also called view level because several users can view their desired data from this
level which is internally fetched from database with the help of conceptual and
internal level mapping.
The user doesn’t need to know the database schema details such as data structure;
table definition etc. user is only concerned about data which is what returned back to
the view level after it has been fetched from database which is present at the internal
level. External level is the top level of the three level DBMS architecture.
2. Conceptual level
It is also called logical level. The whole design of the database such as relationship
among data, schema of data etc. are described in this level.
Database constraints and security are also implemented in this level of architecture.
Page No: 4 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
This level is maintained by DBA (database administrator).
3. Internal level
This level is also known as physical level. This level describes how the data is stored
in the storage devices.
This level is also responsible for allocating space to the data. This is the lowest level
of the architecture.
Page No: 5 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ON table_name (column1, column2, ...);
Example:
The following SQL creates an index named id_firstname on the FirstName column in
the Student table: Correct
explanation of
CREATE INDEX id_firstname DROP INDEX
ON Student (FirstName); Syntax with
example: 2M
DROP INDEX
Syntax:
DROP INDEX index_name ON table_name;
Example:
DROP INDEX id_firstname ON Student;
dbms_output.put_line('reverse is '||rev);
end;
Page No: 6 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Rule 2: Guaranteed Access Rule: all user get access to database
Rule 3: Systematic treatment of null values: null value should be empty
Rule 4: Dynamic online Catalog: record all transactions in database
Rule 5: Data Sub language rule: use only one language
Rule 6: View updating rule: table and view updated simultaneously
Rule 7: High level insert, delete and update: multiple insert delete update
Rule 8: Physical data independence: hardware change
Rule 9: Logical data independence: structure change
Rule 10: Integrity independence: store correct data
Rule 11: Distribution independence: distributed database
Rule 12: No subversion rule: no version of language used.
b) State the use of group by and order by clauses. 4M
Order by Clause:
To view the data in sorted order, the order by clause is used.
By default, the data is sorted in ascending order.
Syntax:
5. SELECT expressions
6. FROM tables
7. [WHERE conditions]
8. ORDER BY expression [ ASC | DESC ];
Example:
declare
name emp_details.ename%type;
cursor a is select ename from emp_details where empno=3;//cursor declaration
begin
open a;//opening the cursor
loop
2M
fetch a into name;//fetching the rows from cursor
update emp_details set comm=3000 where empno=3;
exit when a%notfound;
dbms_output.put_line('record updated');
end loop;
close a;//closing the cursor
end;
2. Consistency:
Consistency means update or edits the same data stored at different locations.
3. Isolation:
Isolation means all the transactions gets executed independent of each other.
4. Durability:
Durability means data can be saved in database permanently until user change it.
Page No: 8 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
1. Schema Definition:
Database or schema can be designed or defined by DBA.
2. Creating storage structure:
DBA allocate or decide the space to store the database.
3. Create grant access methods:
Different access methods to access the database can be granted by DBA to the
users.
4. Schema modification:
The database or schema which is already defined can be modified by DBA as per
the requirements.
5. Granting authorization:
To access the different databases, DBA can grant the authorization to authorized
users only.
6. Performance tuning:
The problems/errors arise in database accessing; can be resolved by DBA to
increase the performance.
7. Regular maintenance:
DBA can monitor the transactions in database and maintain the database error free by
doing the regular maintenance.
OR
Page No: 9 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
CREATE TABLE CUSTOMERS
(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID, NAME)
);
Example:
OR
Page No: 11 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
raise_application_error(-20000,'cannot delete the record'); delete trigger
end;
e) Explain Database Recovery techniques in detail. 4M
3. Checkpoints:
Checkpoint records all committed transactions into logs.
When system fails, it check log to determine recovery action.
a) Draw the overall architecture of DBMS. Explain storage manager and query 6M
processor components.
Page No: 12 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
3. Authorization and Integrity Manager 2M=query
processor
Allows only authorized users to access data and should be hidden from the public
users. The Authorization and Integrity Manager verifies the authority of the user
trying to access the data and it also checks the integrity constraints when the database
is modified.
4. Transaction Manager
A transaction in DBMS is nothing but a very small unit of the program. The
Transaction Manager manages all the transaction (program) execution.
b) Write the SQL queries for following EMP table. Emp (empno, deptno, 6M
ename, salary, designation, city.)
i) Display average salary of all employees.
ii) Display names of employees who stay in Mumbai or Pune.
iii) Set the salary of employee 'Ramesh' to 50000.
iv)Display names of employees whose salaries are less than 50000.
v) Remove the Record of employees whose deptno is 10.
vi) Remove the column deptno from EMP table.
Ans i. select avg(salary) from emp; 1 M each
ii. select ename from emp where city=’Mumbai’ or city=’Pune’;
iii. update emp set salary=50000 where ename=’Ramesh’;
iv. select ename from emp where salary<50000;
v. delete from emp where deptno=10;
c) Write and Explain the syntax for creating, Altering and dropping the 6M
sequence.
Ans 2M
Syntax for creating sequence:
CREATE SEQUENCE sequence_name
START WITH initial_value
INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE ;
.where as:
Page No: 14 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
sequence_name: Name of the sequence.
Example:
CREATE SEQUENCE sequence_1
start with 1
increment by 1
minvalue 0
maxvalue 100
cycle;
Alter sequence:
Syntax:
alter sequence <sequence_name> maxvalue <number>;
Alter sequence can change the maxvalue in the sequence created.
Dropping sequence:
Syntax:
drop sequence <sequence_name>;
To drop the sequence the DROP command is used.
a) Write SQL queries for following. Consider table stud (roll no, name, subl, 6M
sub2, sub3)
i) Display names of student who got minimum mark in subl.
ii) Display names of students who got above 40 marks in sub2.
iii) Display count of Students failed in sub2.
iv) Display average marks of subl of all students.
v) Display names of students whose name start with 'A' by arranging them
in ascending order of subl marks.
vi) Display student name whose name ends with h' and subject 2 marks are
Page No: 15 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
between 60 to 75.
Ans i. select name from stud where sub1= (select min(sub1) from stud); 1 M each
ii. select name from stud where sub2>40;
iii. select count(*) from stud where sub2<40;
iv. select avg(sub1) from stud;
v. select name from stud where name like 'A%' order by sub1;
vi. select name from stud where name like '%h' and sub2 between 60 and 75;
Page No: 16 | 16