Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dma S17 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

Important Instructions to examiners:


1) The answers should be examined by key words and not as word-to-word as given in the model
answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to
assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance
(Not applicable for subject English and Communication Skills).
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant
values may vary and there may be some difference in the candidate’s answers and model
answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.

Q. Sub Answer Marking


No Q.N. Scheme
.
1. (A) Attempt any SIX of the following: 12
(a) Define Database. List any two properties of database. 2M
Ans. Definition:
Database is defined as collection of related data. Definiti
on 1M
Properties of database are:
i) Self-describing nature of a database system Any 2
ii) Insulation between programs and data Properti
iii)Support of multiple views of the data es ½ M
iv) Sharing of data and multi-user transaction processing each
v) Controlling Redundancy.
(b) Define super key. 2M
Ans. Definition: Super key of an entity set is a set of one or more Definiti
attributes whose values uniquely determine each entity. on 2M
(c) List the notation used in relational algebra. 2M
Ans. 1. Selection(σ)
2. Projection (π) Any two
3. Cartesian Product (Χ) notation

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

4. Natural Join( ⋈) 1M
5. Union(U) each
6. Set Difference ( – )
7. Rename (ρ)
(d) Define Group by clause. 2M
Ans. The SQL GROUP BY clause is used along with the SQL aggregate
functions and specifies the groups where selected rows are placed. Descript
When one or more aggregate functions are presented in the SQL ion 2M
SELECT column list, the SQL GROUP BY clause calculates a
summary value for each group.
(e) What is SQL? State its features. 2M
Ans. SQL is an acronym for Structured Query Language an is a standard
relational query language used for creating and manipulating Descript
databases. ion 1M
Features of SQL are:
 SQL allows the user to create, update, delete, and retrieve data Any two
from a database. features
 SQL is very simple and easy to learn. :½M
 SQL works with database programs like DB2, Oracle, each
MS Access, Sybase, MS SQL Sever etc.
(f) Define index. 2M
Ans. Index: An index is a schema object that can speed up the retrieval of
rows by using pointer. An Index provides direct and fast access to Definiti
rows in a table. on 2M
(g) Define cursor. 2M
Ans. The Oracle Engine uses a work area for its internal processing in
order to execute an SQL statement. This work area is private to Definiti
SQL’s operations and is called a Cursor. on 2M
OR
A cursor is a temporary work area created in the system memory
when a SQL statement is executed.
(h) List advantages of Normalization. 2M
Ans. Advantages of the normalization.
 More efficient data structure. Any two
 Avoid redundant fields or columns. advanta
 More flexible data structure i.e. we should be able to add new rows ges 1M
and data values easily each
 Better understanding of data.

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

 Ensures that distinct tables exist when necessary.

1. (B) Attempt any TWO of the following: 08


(a) Describe the advantages of Distributed Database Management 4M
System.
Ans. Following are the advantages of distributed databases over
centralized databases.
1.Modular Development − If the system needs to be expanded to
new locations or new units, in centralized database systems, the
action requires substantial efforts and disruption in the existing
functioning.
2.More Reliable − In case of database failures, the total system of Any 4
centralized databases comes to a halt. However, in distributed advanta
systems, when a component fails, the functioning of the system ges : 1M
continues may be at a reduced performance. Hence DDBMS is more each
reliable.
3.Better Response − If data is distributed in an efficient manner, then
user requests can be met from local data itself, thus providing faster
response.
4.Lower Communication Cost − In distributed database systems, if
data is located locally where it is mostly used, then the
communication costs for data manipulation can be minimized.
5.Local autonomy:
Since data is distributed, a group of users that commonly share such
data can have it placed at the site where they work, and thus have
local control.
6. Expandability:
Expansion can be easily achieved by adding processing and storage
power to the existing network.
(b) What is OUTER JOIN? Explain in detail. 4M
Ans. The SQL OUTER JOIN returns all rows from both the participating
tables which satisfy the join condition along with rows which do not
satisfy the join condition. The SQL OUTER JOIN operator (+) is
used only on one side of the join condition only.

Outer join are of three types: Outer


Join
1. Left outer join (also known as left join): this join returns all the 2M
rows from left table combine with the matching rows of the right

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

table. If we get no matching in the right table it returns NULL


values.

Left Outer Join syntax : SELECT column-name-list from table-


name LEFT OUTER JOIN table-name2 on table-name1.column- Explana
name = table-name2.column-name; tion of
any 1
2. Right outer join (also known as right join): this join returns all the 2M
rows from right table are combined with the matching rows of left
table .If we get no column matching in the left table, it returns null
value.

Right Outer Join Syntax:SELECT column-name-list from table-


name1 RIGHT OUTER JOIN table-name2 on table-
name1.column-name = table-name2.column-name;

3. The full outer join keyword returns all records when there is a
match in either left (table1) or right (table2) table records.

FULL OUTER JOIN Syntax:SELECT column_name(s)from


table1 full outer join table2 on table1.column_name =
table2.column_name;
(c) Describe Exception handling. Explain with example. 4M
(Note: Any example can be considered)
Ans. Exception Handling: Exception is nothing but an error. Exception
can be raise when DBMS encounters errors or it can be raised
explicitly. 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 Descript
code block in memory that will attempt to resolve current error ion
condition. (syntax
Syntax: optional
DECLARE )
; Declaration section 2M
…executable statement;
EXCEPTION
WHEN ex_name1 THEN
:Error handling statements/user defined action to be carried
out;

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

END;
DECLARE
s_rollNostudents.rollNo%type := 10;
s_namestudents.name%type; Exampl
s_addressstudents.address%type; e 2M
BEGIN
SELECT rollNo, name, address FROM students WHERE rollNo =
s_rollNo; dbms_output.put_line(s_rollNo || ' ' || s_name || ' ' ||
s_address);

EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line('No such student!');
WHEN others THEN
dbms_output.put_line('Error!');
END;
2. Attempt any FOUR of the following: 16
(a) Explain referential integrity constraints with example. 4M
(Note: Any other example can be considered)
Ans. Referential integrity constraint:
 It is used to established a parent child relationship between
two tables. Descript
 A value of foreign key is derived from the primary key. ion 2M
 Primary key is defined in a parent table and foreign key is
defined in child table. The child table contains the values for
foreign key column which are present in parent tables primary
key column but not other than that.
Syntax:
Create table tablename (column datatype size references
parenttablename (primary key attribute)….)

Example:
Create table product (EmpId number (4) references Emp (EmpId), Exampl
PName varchar2(10)); e2M

After table creation the foreign key is added as:


Alter table product add constraint fk_prod foreign key (EmpId)
references Emp (EmpId);

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(b) Explain single value and multivalue attribute of E-R model. 4M


Ans. i) Single Valued attribute: Attributes that can have single value at a
particular instance of time are called single valued.
Example: age of a person is a single-valued attribute. Descript
ion of
ii)Multi valued attributes: A multi-valued attribute can have more each
than one value at one time. 2M
Example: phone_no of a person is a multi-valued attribute since a
person can have more than one phone_no.
(c) Explain string, data and time functions of SQL. 4M
Ans. SQL string functions are used primarily for string manipulation.
Following are the string functions used in SQL.

Any 2
String
function
s 1M
each

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

Any 2
date
time
function
s 1M
each

(d) With the help of example, explain DROP VIEW command. 4M


Ans. DROP VIEW statement: Drops the specified view.
Explana
Syntax: tion 2M
DROP VIEW view-Name;
Example:
Exampl
DROP VIEW emp-view;
e2M
Explanation:
Any statements referencing the view are invalidated on a DROP
VIEW statement. DROP VIEW is disallowed if there are any views
or open cursors dependent on the view. The view must be dropped
before any objects that it is dependent on can be dropped.
(e) Write a PL/SQL program to print numbers from 50 to 60 using 4M
for loop.
(Note: Any other Logic also considered) Correct
Ans. DECLARE program
x number :=50; 4M

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

BEGIN
LOOP
dbms_output.put_line(x);
x := x +1;
IF x >60 THEN
exit;
END IF;
END LOOP;
END;
(f) List and explain types of DBMS users. 4M
Ans. List of DBMS user:
a) Naive users
b) Application programmers
c) Sophisticated users List
d) Specialized users 1M
e) Database administrator

Explanation:
a) Naive User: Explana
 Naïve users are unsophisticated users tion of
 They are interact with the system through the application any 3
program. 1M each
 They give data as input through application program or get
output data which is generated by
 application program.
 Example: Bank cashier.
b) Application programmers:
 Application programmers are the users who write the
program.
 These programmers use programming tools to develop the
program.
 RAD technology is used to write the program.
c) Sophisticated users:
 Sophisticated users interact with the system by making the
requests in the form of query
language.
 These queries are then submitted to the query processor.
 Query processor converts the DML statements into lower

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

level interactions which are understandable by storage


manager.
 Some sophisticated users can be analyst.
d) Specialized users:
 These users are not traditional.
 They write some special application programs which are not
regular applications.
 Example: such types of applications are CAD, knowledge
based and expert system.
e) Database administrator:
 Responsible for managing whole database system , create and
maintains database.
 Manages users who can access the database and manages
integrity issue.
 Manages performance of system as and when required.
3. Attempt any FOUR of the following: 16
(a) Explain having clause with example. 4M
(Note: Any other example considered)
Ans. Having clause is used to filter data based on the group functions. This
is similar to WHERE condition but is used with group functions. Descript
Group functions cannot be used in WHERE Clause but can be used in ion 2M
HAVING clause.
Syntax
SELECT column1, aggregate_function(column2)
FROM table1, table2
WHERE [ conditions ]
GROUP BY group_expression
HAVING [ conditions ]
ORDER BY column1, column2

Example:
SQL > SELECT ID, NAME, AGE, ADDRESS, MIN(SALARY) Exampl
FROM CUSTOMERS e 2M
GROUP BY ID
HAVING MIN(SALARY)>=2000;
(b) Explain implicit and explicit cursor. 4M
Ans. Implicit Cursor:
Implicit cursors are automatically created by Oracle whenever an
SQL statement is executed, when there is no explicit cursor for the

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

statement.
Whenever a DML statement (INSERT, UPDATE and DELETE) is
issued, an implicit cursor is associated with this statement. For
INSERT operations, the cursor holds the data that needs to be
inserted. For UPDATE and DELETE operations, the cursor identifies
the rows that would be affected.
In PL/SQL, implicit cursor as has the attributes like %FOUND,
%ISOPEN, %NOTFOUND, and %ROWCOUNT.
Descript
Example of implicit cursor: ion or
Begin example
Update emp set salary= salary +500 where empno =&empno; 2M for
If SQL%FOUND then each
Dbms_out.put_line(―Emp table modified‖); type
Else
Dbms_out.put_line(―Emp table modified‖);
End if;
End;

Explicit cursor:
Explicit cursors are programmer defined cursors for gaining more
control over the context area.
An explicit cursor should be defined in the declaration section of the
PL/SQL Block. It is created on a SELECT Statement which returns
more than one row.

Working with an explicit cursor involves four steps:


Declaring the cursor for initializing in the memory
Cursor cursor_name IS select_statement;
Opening the cursor for allocating memory
Open cursorname;
Fetching the cursor for retrieving data
Fetch cursorname INTO variable1,variable2…
Closing the cursor to release allocated memory
Close cursorname;

Example of explicit cursor:


Declare
Cursor c1 is select empno, salary from emp Where deptno=10;

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

ecode emp.empno%Type;
sal emp.salary%Type;
Begin
Open c1;
If c1%ISOPEN then
Loop
Fetch c1 into ecode,sal;
If c1% NOTFOUND then Exit;
End if;
Update emp set salary = salary+500;
End Loop;
Close c1;
Else dbms_out.put_line(―unable to open‖);
End if;
End;
(c) Explain strong and weak entity set with example. 4M
Ans. Strong Entity Set: An entity set that has sufficient attributes to form
a primary key iscalled as strong entity set.

Example: Cust_id is a primary key of Customer Entity so customer is Each


strong entity set.. entity
descripti
Weak Entity set: An entity set that does not have sufficient attribute on 1M
to form a primary key is called as Weak Entity Set.

Example: transaction is not having sufficient attribute to form a


primary key so, transaction a weak entity set

Exampl
e 1M
each
(diagra
m
optional
)

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(d) Differentiate between view and index. 4M


Ans. Parameter View Index
Definition A view is a virtual table, An index is a schema
through which a selective object that can speed up
portion of data from one the retrieval of rows by
or more tables can be using pointer.
seen Any 2
Function View restrict access to Index provides direct relevant
data such that user can and fast access to rows points :
see and modify exactly in a table 2M
what they need and no Each
more.
Syntax CREATE VIEW Create index
view_name AS index_name on
SELECT column1, Table_name
column2..... (coloumn_name);
FROM table_name
WHERE [condition];
Example CREATE VIEW create index s_index
CUSTOMERS_VIEW on Student(roll_no);
AS SELECT name, age
FROM CUSTOMERS;
(e) Explain the concept of trigger. 4M
Ans. A trigger is a PL/SQL block structure which is fired when DML
statements like Insert, Delete, Update is executed on a database table.
A trigger is triggered automatically when an associated DML
statement is executed.

Syntax for Creating a Trigger:


CREATE OR REPLACE TRIGGER trigger_name Descript
[BEFORE/AFTER] ion 4M
[INSERT/UPDATE/DELETE] (Exampl
ON Table_name [FOR EACH STATEMENT/FOR EACH ROW] e
[WHEN CONDITION] Optiona
PL/SQL block l)

Example:
CREATE OR REPLACE TRIGGER trg1

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

BEFORE INSERT ON EMP


FOR EACH ROW
BEGIN
IF :new.sal<=0 THEN
Rasie_application_error(‘Salary should be greater than 0’);
END IF;
END;
(f) Describe function of database administrator. 4M
Ans. Function of database administrator
1.Schema Definition
The Database Administrator creates the database schema by Any 4
executing DDL statements. Schema includes the logical structure of function
database table (Relation) like data types of attributes, length of s :1M
attributes, integrity constraints etc. each

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.

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.

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

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.
4. Attempt any FOUR of the following: 16
(a) Draw E-R diagram for customer and loan. Assume suitable 4M
attribute.
Ans.

Correct
use of
symbols
2M

OR Correct
entities
and
relation
ships
2M

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(b) Define following term with example. 4M


(i) Procedure
(ii) Function
Ans. (i) Procedure:
Definition: A procedure is named PL/SQL block which perform one
or more specifies task. Each
term
Example :Definiti
on 1M,
The following example creates a simple procedure that displays the
string 'Hello World!' on the screen when executed. Exampl
e:1M
CREATE OR REPLACE PROCEDURE greetings
AS
BEGIN
dbms_output.put_line('Hello World!');
END;

(ii) Function:

Definition: Function is a logically grouped set of SQL and Pl/SQL


statements that perform a specific task.

Example:
This function returns the total number of CUSTOMERS in the
customers table.

CREATE OR REPLACE FUNCTION totalCustomers


RETURN number IS
total number(2):=0;
BEGIN
SELECT count(*)into total
FROM customers;

RETURN total;
END;
/

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(c) Describe commit and rollback with proper syntax. 4M


Ans. Commit:
The COMMIT command is used to save changes invoked by a
transaction to the database. For
The COMMIT command saves all transactions to the database since each
the last COMMIT or ROLLBACK command. explanat
The syntax: ion
SQL> COMMIT; :1M
Or
COMMIT WORK;

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.
Syntax
We can either rollback the entire transaction or till a particular save 1M each
point transaction can be rolled back.
The syntax for ROLLBACK is:
ROLLBACK TO SAVEPOINT_NAME;
OR
ROLLBACK;
OR
ROLLBACK WORK;
(d) Consider the structure for book table as Book-master = {bookid, 4M
bookname, subcode-author, no_of copies, price} Write SQL
queries for following:
(i) Display total no. of books for subject ‘DBM’
(ii) Get authorwise list of all books.
(iii) Display all books whose prices are between Rs.200 and
Rs.500
(iv) Display all books with details whose name start with ‘S’
(Note: Queries with any other correct logic shall be considered) Each
Ans. (i)select sum(no_of Copies) from Book_master where subcode= correct
‘ DBM’; query
(ii) Select SUM(no_of Copies),author from Book_master group by 1M
(author);
(iii) Select bookname from book_master where price>=200 and price

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

<=500;
(iv) select * from book_master where bookname like ‘S%’;

(e) Describe unique index and composite index with example. 4M


Ans. Unique Index:
Unique indexes are used not only for performance, but also for data
integrity. An unique index does not allow any duplicate values to be Explana
inserted into the table. tion of
The basic syntax is as follows: each
CREATE UNIQUE INDEX index_name on table_name 1M
(column_name);
Exampl
Example: e of
CREATE UNIQUE INDEX ename_idx on emp (ename); each 1M
Composite Index:
A composite index is an index created on two or more columns of a
table.
The basic syntax is as follows:
CREATE INDEX index_name
on table_name (column1, column2);
Example:
CREATE INDEX en_idx
on emp (ename,job);
(f) List out query processing components and state their function. 4M
Ans. Components of query processing:
1)DDL interpreter List 1M
2) DML compiler
3) Embedded DML PreCompiler
4) Query Evaluation Engine

The query processor components include:


1. DDL Interpreter: It interprets DDL statements and records them Descript
in a set of tables containing metadata or data dictionary. ion of
any 3
2. DML Compiler: It translates DML statements of high level query 1M each
language into low level instructions that query evaluation engine
understands.

3. Embedded DML PreCompiler: It converts DML statements

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

embedded in application program to normal procedural calls in host


language. The precompiler must interact with the DML compiler to
generate the appropriate code.

4. Query Evaluation Engine: It executes low level instructions


generated by DML compiler and DDL

5. Attempt any FOUR of the following: 16


(a) Explain three tier architecture. 4M
Ans. In three tier architecture, the communication taken place from client
to application server and then application server to database system to
access the data. The application server or web server is sometimes
called middle layer or intermediate layer. The middle layer which
processes applications and database server processes the queries. This Explana
type of communication system is used in the large applications or the tion 4M
world web applications. On WWW all clients requests for data and
server serves it. There are multiple servers used like fax server, proxy (Diagra
server, mail server etc. m
optional
)

(b) Explain snapshot with example. 4M


Ans. Snapshot:
It is also known as materialized view. 
It is a copy of either an entire single table or set of its rows or Snapsho
collection of tables, views or rows using join, grouping and t
selection criteria.  explanat
Useful in distributed environment  ion 2M
It has two types:
Simple snapshot and complex snapshot. Simple snapshot
related to single table and complex snapshot related to joined

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

tables.
Example :
Operations on snapshot:

i) Creating Snapshot:
Create snapshot command is used to create the snapshot.
Syntax:- Any one
CREATE SNAPSHOT [schema.] <snapshot name>AS subquery; operatio
Example:- ns
Create snapshot emp_snapas select * from emp where example
deptno=6; :2M

ii) Altering snapshot:


Snapshot can be altered by using ALTER SNAPSHOT command.
The only parts ofa snapshot that can be altered are its storage
parameters, refresh type and refresh start,and next interval. The select
for the snapshot, base tables, and other data related items
cannot be changed without dropping and recreating the snapshot.
Syntax:-
ALTER SNAPSHOT <snapshotname>
[[PCTFREE <integer>]
[PCTUSED <integer>]
[REFRESH [FAST/COMPLETE/FORCE]];
Example:-
To change the automatic refresh mode for the emp_data snapshot to
fast:
ALTER SNAPSHOT emp_data REFRESH FAST;

iii) Dropping a snapshot


To remove the snapshot DROP SNAPSHOT Command .When
snapshot is dropped which a snapshot log had associated with it, only
the rows required for maintainingthat snapshot are dropped.
Syntax:-
Drop snapshot <snapshot name>;
Example:-
Drop snapshot emp_snap;

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(c) Explain GOTO statement with example. 4M


Ans. The GOTO statement transfers control to a labelled block or
statement.
It is an unconditional branching statement. Explana
It does not use any condition for transferring the control to other part tion
of code. 2M
It transfers the control to the part of code which contains same label
mentioned in goto statement.
Syntax :
GOTO label;
..
..
<< label >>
statement;

Example :
DECLARE
p VARCHAR2(30); Exampl
n PLS_INTEGER := 37; e 2M
BEGIN (any
FOR j in 2..ROUND(SQRT(n)) LOOP other
IF n MOD j = 0 THEN example
p := ' is not a prime number'; consider
GOTO print_now; ed)
END IF;
END LOOP;
p := ' is a prime number';
<<print_now>>
DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || p);
END;
(d) Explain PL/SQL block structure. 4M
Ans. Block structure of PL/SQL:
Declare Correct
block
Declaration of memory variables
structur
BEGIN (Mandatory) e 3M
SQL executable statements
Exception

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

Handling errors
END; (Mandatory)
A block begins with a declarative section where variables are
declared. This is followed by a section containing the procedural Explana
statements surrounded by BEGIN and END keywords. Each block tion 1M
must have Begin and End statements and may optionally include an
exception section to handle errors. End section marks the end of PL-
SQL block
(e) Explain candidate key and primary key. 4M
Ans. Candidate key:
In a relation, there may be a primary key or may not, but there may 2M
be a key or combination of keys which uniquely identify the record. each
Such a key is called as Candidate key.

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.
(f) Explain concurrent execution of multiple transaction in detail. 4M
Ans. A transaction is a collection of operations that perform modifications
in database application.
A set of transactions can be executed by some sequence which is
called as a schedule.
There are two types of schedules as serial executions and concurrent Explana
execution. tion
When two transactions are executed one after the other, it is called as 4M
serial execution and when they are interleaved, it is called as
concurrent execution of transaction.
Concurrent execution should always preserve consistency. This
means that even if the transactions are interleaved, there should not
be any damage to data.

Example :
Transaction T1 :Rs. 50 of A’s account are transferred to B’s Account.
Transaction T2 : 10% of A’s balance is transferred to B’s Account
Consider initial amount as A=100, B=150 so initially A+B=150
Concurrent schedule will appear as :

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

T1 T2
Read(A); ……A=100
A:=A-50;
Write(A); …..A=50
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); …..B=150
B:=B+50;
Write(B); …...B=200
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205

Initially A=100, B=150 therefore A+B=250.

At the end of both the transactions in above concurrent schedule. The


consistency is preserved. i.e., A=45, B=205 and therefore A+B=250

6. Attempt any FOUR of the following: 16


(a) Explain client-Server architecture. 4M
Ans. Client server is a system in which all the data & information is stored
on the server & all application programs are stored on the client. In
this client server relationship, several clients can share the same Explana
server. tion 4M

Diagra
m
Optiona
l
Computer networking allows some task to be executed on a server
system and some tasks on client system. This leads to development of
client server architecture. The clients are the machines which requests
for the service to the server. Server is the machine which serves to the

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

clients.
There are different types of client/server architecture such as
• Two tier architecture,
• Three tier architecture.
In two tier architecture, client systems directly approach database
servers whereas in three tier architecture, there exists a middle layer
which acts as application server to receive and send requests from
client machine to database server and vice versa
(b) Explain Third normal form.
Ans.  3NF (Third normal form)
1) After removing all transitive dependencies and making
separate relations, relations get into 3NF.
2) Transitive dependency is can be stated as, let R be relation
and A, B and C be the set of attributes then, they are transitive
dependent if C depends on B, B depends on A and therefore C
depends on A. 4M

Example

Student_Detail Table :
Student_id Student_name DOB Street city State Zip Explana
tion 3M

In this table Student_id is Primary key, but street, city and state
depends upon Zip. The dependency between zip and other fields is
called transitive dependency. Hence to apply 3NF, we need to move
the street, city and state to new table, with Zip as primary key.
New Student_Detail Table : Exampl
e 1M
Student_id Student_name DOB Zip

Address Table :
Zip Street city State

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(c) Describe state of transaction with neat diagram. 4M


Ans.

Diagra
m 2M

A transaction must be in one of the following states: Explana


tion 2M
1. Active: the initial state, the transaction stays in this state while it is
executing.
2. Partially committed: after the final statement has been executed.
3. Failed: when the normal execution can no longer proceed.
4. Aborted: after the transaction has been rolled back and the
database has been restored to its state prior to the start of the
transaction.
5. Committed: after successful completion.

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(d) Draw E-R diagram for airline reservation system. Here a 4M


passenger can book ticket from personal for a flight on same
date.
Ans.

Correct
use of
symbols
2M

Correct
entities
and
relation
ships
2M

(e) Describe serializability. 4M


Ans. In concurrent execution of transaction, if the consistency level of the
concurrent schedule is same as the consistency level after serial
schedule of the same schedule, then that concurrent schedule is called
as serializable concurrent schedule and this property of schedule is
called as serializability. Descript
Serializability ensures consistency of database. ion with
Example : suitable
Transaction T1: Rs. 50 of A’s account are transferred to B’s Account. example
Transaction T2 : 10% of A’s balance is transferred to B’s Account 4M
Consider initial amount as A=100, B=150 so initially A+B=250
Serial Schedule appears as
T1 T2
Read(A);
……A=100
A:=A-50;
Write(A); …..A=50

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

Read(B); …..B=150
B:=B+50;
Write(B);
…...B=200
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205

At the end of serial schedule, A+B=250


Concurrent schedule will appear as:

T1 T2
Read(A);
……A=100
A:=A-50;
Write(A); …..A=50
Read(A); …..A=50
Temp:=A*0.1;
A:=A-temp;
Write(A); …..A=45
Read(B); …..B=150
B:=B+50;
Write(B);
…...B=200
Read(B); ……B=200
B:=B+temp;
Write(B); ……B=205

Here also A+B=250 at the end of schedule, so this concurrent


schedule preserves consistency and hence it is a serializable schedule
and shows serializability property

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

MODEL ANSWER
SUMMER - 2017 EXAMINATION
Subject: Relational Database Management System Subject Code: 17332

(f) Explain locking strategy in detail. 4M


Ans. Implicit Locking:
Implicit locks are generally placed by the DBMS automatically.

Explicit Locking:
The technique of lock taken on a table or its resources by a user is
called Explicit Locking. Explana
Users can lock tables they own or any tables on which they have been tion 4M
granted table privileges (such as select, insert, update, delete).
Explicit locking done by two ways as

1) The Select........For Update statement


It is used for acquiring exclusive row level locks in anticipation of
performing updates on records.

2) Using lock table statement:


To manually override Oracle’s default locking strategy by creating a
data lock in a specific mode.

Syntax:
LOCK TABLE <TableName> [, <TableName>]…
IN { ROW SHARE| ROW EXCLUSIVE|SHARE
UPDATE|SHARE|SHARE ROW EXCLUSIVE|EXCLUSIVE}
[NOWAIT]

Page 27 / 27

You might also like