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

RDBMS

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

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
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) List the application of database management system. 2M
Ans. 1. Banking
2. Airlines Any two
3. Universities applicati
4. Credit Card transactions on 1M
5. Telecommunication: each
6. Finance
7. Sales.
8. Manufacturing
9. On-line Retailers
(b) Write advantages of network model. 2M
Ans 1) Conceptual simplicity- network model is also conceptually simple Any 2
and easy to design. advanta
ges list
2) Capability to handle more relationship types-The network only
model can handle the one to many and many to many relationships 1M each
which is real help in modeling the real life situations.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
3) Ease of data access-The data access is easier and flexible than the
hierarchical model.

4) Data integrity- The network model does not allow a member to


exist without an owner.

5) Data independence- The network model is better than the


hierarchical model in isolating the programs from the complex
physical storage details.
(c) Explain foreign key constraint. 2M
Ans It is used to establish the parent child relation between two tables. Correct
Value of foreign key is derived from primary key. explanat
Primary key is defined into parent table and foreign key is defined ion
into child table. 2M
(d) What are the different data types of SQL. 2M
Ans 1.Char Any
2.Number four
3.varchar /varchar2 data
4.Long types ½
5. Date M each
(e) What is serializability? 2M
Ans When multiple transactions run concurrently, then it may give rise to Correct
inconsistency of the database. Serializability is a concept that helps to definitio
identify which non-serial schedules are correct and will maintain the n 2M
consistency of the database.
(f) What is view? 2M
Ans A VIEW in SQL is a logical subset of data from one or more tables. Correct
definitio
n 2M
(g) Define following with respect to PL/SQL. 2M
(i) Function
(ii) Procedure

Ans (i)Function:
A function is a logically grouped set of SQL and PL/SQL statements Correct
that perform a specific task. definitio
n 1M
(ii) Procedure: each
It is named PL/SQL block which performs one or more specific task

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(h) Define the terms : 2M


(i) Candidate Key
(ii) Primary Key

Ans (i) Candidate Key Correct


Sometimes in relation, there are more than one attributes are having definitio
the unique identification property. Those attributes are known as n 1M
candidate key. each

(ii) Primary Key


Within a relation there is always one attribute which has values that
are unique in a relation also not null, thus can be used to identify
tuple of that relation. Such a unique identifier is called the primary
key.

(B) Attempt any TWO of the following : 8


(a) Explain 3 levels of data abstraction with suitable diagram. 4M
Ans Three levels of abstraction are as follows:
1) Physical level Diagram
2) Logical level 2M
3) View level
Diagram: Descript
ion 2M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Explanation:

1. Physical Level:
 It is lowest level of abstraction.
 This level defines lowest complicated data structure of database
system.
 This level hidden from user.
 It defines how the data are stored.

2. Logical Level:
 The level next to physical level is called logical level.
 This level defines what data stored in the database and what the
relationships among these data are.
 Fully decides the structure of the entire database.

3. View Level:
 This level is used to show the part of database to user.
 There is more complexity in physical as well as logical level so
user should not interact with complicated database.
 So different view of database can be created for user to interact
with database easily

(b) Describe the command to change the data in the table with 4M
example.

Ans Update statement is used to modify the data in a table. Syntax /


To update selective rows from the table where the specified descripti
condition gets satisfied. on 2M

Syntax : Example
Update <tablename> set <attribute_name1=expression1> where 2M
<search_condition>;

Example: update student set age=18 where s_id=102;

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(c) Compare database triggers and procedures. 4M


Note: Any other relevant comparison shall be considered.
Ans Any 4
Database Trigger Procedures relevant
differen
1. Triggers are fired when 1. Procedures are executed ces
particular SQL commands when they are called 1M
each
(DML) are executed
2. Triggers have events and 2. Procedure do not have
related actions events and related actions
3. Triggers are called 3. Procedure are called
implicitly explicitly
4. Triggers cannot accept 4. Procedures can accept
parameters parameters.

2 Attempt any FOUR of the following 16


(a) Explain network model with a suitable diagram. 4M
Note: Any other relevant diagram or example shall be considered.
Explana
Network model:
Ans tion
1. This model is introduced by Charles Bachman. 3M
2. The network model is a database model.
3. We can represent objects and relationships. Nodes are objects and Diagram
relationships are links. 1M
4. Network Model is based on tree like structure with many roots.
5. One to many (1:N) or many to many(M:M) relationship is
maintained.
6. Network Model is more popular as compare to the Hierarchical
model.
7. In Network Model, data is represented as a collection of records
of fixed format. Records are physically linked through linked list.
8. In database, data is organized as a graph.
9. It uses client server architecture. It is mainly used in network

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(b) Compare BCNF and 3NF with suitable example. 4M


Ans
Any 2
BCNF 3NF points
Redundancy is low compared Redundancy is high compared 1M each
to 3NF to BCNF
It concentrates on candidate It concentrate on primary key. Example
keys of each
It may not preserve all It may preserve all 1M
functional dependencies dependencies
For any trivial dependency in No non-prime attribute must be
a relation R say X->Y, X transitively dependent on the
should be a super key of Candidate key
relation R.
Lossless decomposition is Lossless decomposition can be
hard to achieve in BCNF. achieved in 3NF.

Example OF 3NF
A bank uses the following relation:
Vendor(ID, Name, Account_No, Bank_Code_No, Bank)
The attribute ID is the identification key. All attributes are single
valued (1NF). The table is also in 2NF.The following dependencies
exist:

1. Name, Account_No, Bank_Code_No are functionally dependent


on ID
(ID --> Name, Account_No, Bank_Code_No)

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

2. Bank is functionally dependent on Bank_Code_No


(Bank_Code_No --> Bank)

There is a transitive dependency between Bank_Code_No and Bank,


because Bank_Code_No is not the primary key of this relation. To get
to the third normal form (3NF), we have to put the bank name in a
separate table together with the clearing number to identify it.

Vendor(ID, Name, Account_No, Bank_Code_No)


Bank(Bank_Code_No,Bank)

Example of BCNF:
Let's assume there is a company where employees work in more than
one department.
EMPLOYEE tableEMP_ID,EMP_COUNTRY,EMP_DEPT,
DEPT_TYPE,EMP_DEPT_NO)

In the above table Functional dependencies are as follows:


1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate key: {EMP-ID, EMP-DEPT}
The table is not in BCNF because neither EMP_DEPT nor EMP_ID
alone are keys.
To convert the given table into BCNF, we decompose it into three tables:
1.EMP_COUNTRY table: EMP_ID → EMP_COUNTRY
2.EMP_DEPT table: EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
3.EMP_DEPT_MAPPING table: EMP_ID,EMP_DEPT

Functional dependencies
1. EMP_ID → EMP_COUNTRY
2. EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
For the first table: EMP_ID
For the second table: EMP_DEPT

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

For the third table: {EMP_ID, EMP_DEPT}


Now, this is in BCNF because left side part of both the functional
dependencies is a key.
(c) Consider the structure of stud record (Name, Mark, Age, Place, 4M
Phone, Birth_date)
Write SQL queries for following:
(i) To list the name of student who do not have phone no.
(ii) To list the students from Nashik and Pune
(iii) To change mark of Monika to 88 instead of 80
(iv) To list the student’s from Amit’s age group

Note: Here table name is considered as studrecord


Ans (i) To list the name of student who do not have phone no.
Select Name from studrecord Where Phone IS NULL;
For
(ii) To list the students from Nashik and Pune each
Select Name from studrecord Where Place=‟Nashik‟ or query
Place=‟Pune‟; 1M
(or)
Select Name from studrecord Where Place in(‟Nashik‟ ,‟Pune‟)

(iii) To change mark of Monika to 88 instead of 80


Update studrecord Set Mark=88 Where Name=‟Monika‟;

(iv) To list the student’s from Amit’s age group


Select Name from studrecord Where Age=(Select Age from Student
Where Name=‟Amit‟);

(d) Write command & its syntax for 4M


(i) creating snapshot
(ii) to view the record from snapshot
(iii) altering snapshot
(iv) dropping snapshot Each
Ans i) Creating Snapshot: comman
Create snapshot command is used to create the snapshot. d with
Syntax:- syntax
CREATE SNAPSHOT [schema.] <snapshot name>AS subquery; 1M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

ii)to view a record from snapshot


select command is used to view record from snapshot.
Syntax :
Select */<column list> from <view name>;

iii) Altering snapshot:


Snapshot can be altered by using ALTER SNAPSHOT command.
The only parts of a 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]];

iv) 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 maintaining that snapshot are dropped.

Syntax:-
Drop snapshot <snapshot name>;

(e) Describe Grant and Revoke Commands. 4M


Ans Grant: This command is used to give permission to user to do
operations on the other user‟s object. Descript
ion of
Syntax: each
Grant<object privileges>on<object name>to<username>[with grant comman
option] ; d
2M
Example: Grant select,update on emp to user1;

Revoke: This command is used to withdraw the privileges that has


been granted to a user.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Syntax:
Revoke <object privileges>on<object name>from <username> ;

Example: Revoke select, update on emp from user1;


(f) Explain overall structure of DBMS 4M
Ans Components of DBMS are classified in three categories.
Query processor Relevant
1. DDL Interpreter: It interprets DDL statements and records them Explana
in a set of tables containing metadata or data dictionary. tion 4M
2. DML Compiler: It translates DML statements of high level query
language into low level instructions that query evaluation engine
understands.
3. Compiler and linker or Embedded DML PreCompiler: It
converts DML statements 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 interpreter.

Storage Manager
1. Authorization and integrity manager
Which tests for the satisfaction of integrity constraints and checks the
authority of users to access data.

2. Transaction manager
Which ensures that the database remains in a consistent correct) state
despite system failures, and that concurrent transaction executions
proceed without conflicting.

3. File Manager
It manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.

4. Buffer manager
Which is responsible for fetching data from disk storage into main
memory, and deciding what data to cache in main memory.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Disk Storage
i. Data files, which store the database itself.
ii. Data dictionary, which stores metadata about the structure of
the database, in particular the schema of the database.
iii. Indices, which provide fast access to data items that hold
particular values.
iv. Statistical Data: It stores statistical information about the data
in the database.

3 Attempt any FOUR of the following: 16


(a) What are different alter commands in SQL? Explain with 4M
example.
Ans Alter command is a DDL command. It is used to change the structure Explana
of an existing table. The different types of alter queries are: tion of
Alter-add: alter add
Alter-add is used to add a new column to an existing table. It can be with
also used to add primary key, foreign key, unique, check constraints. example
General syntax 2M
for adding column:
alter table <tablename> add <columnname><datatype><(size)> Explana
for adding constraints: tion of
alter table <tablename> add constraint <constraintname><constraint alter-
type>(column name) modify
with
Example example
alter table student add emailid varchar2(50); 2M
alter table student add constraint pk_student primary key(student_id);
Alter-modify:
alter-modify is used to change the structure of an existing column in a
table or to add a not null constraint
General syntax:
alter table<tablename> modify <columnname><datatype>(size);
alter table <tablename> modify columnname not null

(b) Explain looping in PL/SQL. 4M


Ans A loop is used to execute a set of statements repeatedly. the different
loops in PL/SQL are:

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

1. simple loop For


General syntax: listing
initialization; loops
loop 1M
body of the loop
incr/decr;
exit when condition;
end loop;
The looping variable is initialized first. The body of the loop gets
executed and the increment or decrement of the looping variable is explanat
done. This step executes repeatedly till the exit condition turns true. ion of
The condition is checked at the end. each
2. while loop 3M
General syntax:
intialization
while condition loop
body
incr/decr
end loop
The initialization of the loop variable is done first. The condition is
checked as the next step. If the condition is true, the statements in the
body of the loop get executed. Further, increment and decrement of
the looping variable is done. The steps are executed till the condition
in the while loop turns false.
3. for loop
General syntax:
forloop_variable in initial_value .. final_value loop
body
end loop
The looping variable is initialized to the initial_value. It is then
compared to the final value. If true, then the body of the loop gets
executed. The value of the looping variable is incremented by 1. The
looping variable is compared to the final value and the steps repeat
till the condition turns false.
To print in reverse, the general syntax:
forloop_variable in reverse initial_value .. final_value loop
body
end loop

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(c) Describe ACID properties of transaction 4M


Ans A transaction is a single unit of execution. It can have different steps.
Every transaction in the DBMS must follow the ACID properties.
The ACID properties are:
A-Atomicity
C-Consistency
I-Isolation Explana
D-Durability tion of
Atomicity- This property states that every transaction should be each
treated as an atomic unit that is, either the entire transaction should be property
completed totally or it should not be done at all. It also states that 1M
under no condition should a transaction be partially completed.
Consistency- The database must remain in consistent state after any
transaction. The execution of a transaction should not result in
inconsistency of the database.
Isolation-in systems where more than one transaction execute
simultaneously and in parallel, all transaction will be carried out and
each transaction should feel that it is the only transaction happening.
If Ti,Tj are two transactions, then Ti should feel that it is the only
transaction happening while it is executing, either Tj should have
completed execution or will execute once Ti completes.
Durability- The database should be durable enough to hold all its
latest updates even if the system fails or restarts. If a transaction
updates 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 starts.

(d) How to create views? Explain any two options of views. 4M


Note: Any relevant example shall be considered however general
syntax is expected.
Ans A view is a virtual table based on the result set of the SQL statement. Create
To create a view, the create view query is used. views
2M
General syntax:
create view viewname as select query. Any two
Example: options
create view vw_student as select stud_id, stud_name,ssc_per from 2M
student;

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
The different options in view are:
1. OR REPLACE option: it recreates the view, if a view by the name
already exists.
2.
3. FORCE option: it creates the view regardless of whether the tables to
which the view refers exist or whether the user has privilege on them.
The user cannot still execute the view but the user can create it.
4. NO FORCE option: it creates the view only if the base tables exist
and the user has privileges on them
5. WITH CHECK option: it restricts inserts and updates performed
through the view to prevent them from creating rows that the cannot
itself select based on the where clause of the CREATE VIEW
statement. It may be used in a view that is based on another view.
6. WITH READ ONLY: if the view is created with WITH READ
ONLY, then only select is allowed against the view. No data
manipulation is allowed

(e) Draw & explain the block structure of PL/SQL. 4M


Ans
Diagram
Declaration 1M
Block
Execution Block

Exception Block

The declaration section is used to define data types, structures,


and variables. Variables can be declared in the declaration section by Explana
giving them names, data types, and initial values. It starts with the tion of
keyword „Declare‟. Each
block
The execution section is required in a block structure and it must have 3M
at least one statement. The execution section is the place where the
execution code or business logic code is placed in PL/SQL.
Procedural code and SQL statements can be written inside the
execution section. It starts with the keyword „Begin‟.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

The exception handling section is starting with the Exception


keyword. The exception section is the place where the code to handle
exceptions are put.
(f) Explain two tier and three tier client server architecture. 4M
Ans Two tier architecture:
The following is true for two tier architecture Two tier
The application is partitioned into a component that resides at the architect
client machine which invokes database system functionality at the ure 2M
server machine through query language statements.
Application program standards like ODBC and JDBC are used for Three
interaction between the client and the server. tier
architect
ure 2M

Three tier architecture:


The three tier architecture includes the following:
Clients contain GUI interfaces and some additional application-
specific business rules.
The intermediate server also known as application server accepts
requests the clients, processes the requests and sends database
commands to the database server. It acts as a conduit for passing
(partially processed data from the database server to the clients,
when it may be processed further and filtered to be presented to
users in GUI format.
Thus the user interfaces, application rules and the database
comprises of the three tier architecture

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
4 Attempt any FOUR of the following: 16
(a) Explain the term Specialization and Generalization with suitable 4M
example
Ans Generalization: Generalization is super class in DBMS which holds
common properties/ attributes for more than one entities (Specialized
class). In generalization, the higher level entity can also combine with
other lower level entity to make further higher level entity.
Explana
tion of
each
term
with
suitable
example
2M

Specialization: Specialization holds special attributes of entities


which are distinguished from other entities of same type.
Specialization is opposite to Generalization. In specialization, some
higher level entities may not have lower-level entity sets at all.

(b) Write a PL/SQL program to print numbers 1 to 7 using for loop. 4M


Ans begin
for i in 1 ..7 loop Syntax
dbms_output.put_line(i); 2M
end loop; Correct
end; Logic
2M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(c) Explain the use of truncate statement and rename statement. 4M


Give example
Ans Truncate- It is a DDL query. It is used to delete all the rows of a Explana
table. Conditional delete is not possible with truncate. This query is to tion with
be used with caution as the rows so deleted may not be brought back example
using roll back. 2M each
General syntax
Truncate table <tablename>
Example:
Truncate table student;
This query will delete all the rows of the table student.

Rename- It is a DDL query and is used to rename a table.


General syntax:
Rename <old_table_name> to <new_table_name>
Example:
rename student to stud_details

(d) List & explain set operators in SQL. 4M


Note: Example is optional.
Ans Set operators combine the results of two component queries into a
single result. Queries containing set operators are called as compound List
queries. Set operators in SQL are represented with following special 2M
keywords as: Union, Union all, intersection & minus.
Explana
1) Union : The Union of two or more sets contains all elements, tion of
which are present in either or both. Union works as or. The duplicates each
of both the tables will appear only once. operator
Example: ½M
select ename from emp1 union select ename from emp2;

2) Union all : The Union of 2 or more sets contains all elements,


which are present in both, including duplicates.
Example:
select ename from emp1 union all select ename from emp2;

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


are present in both.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Example:
select ename from emp1 intersect select ename from emp2;

4) Minus: The minus of two sets includes elements from set1 minus
elements of set2.
Example:
select ename from emp1 minus select ename from emp2;

(e) Draw an E-R diagram for Hospital Management System. 4M


Ans
Use of
correct
entities
1M

Correct
symbols
2M

Correct
relations
hips
1M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(f) Explain types of database users. 4M


Ans List of DBMS user:
a) Naive users Any 4
Naïve users are unsophisticated users. They interact with the system types
through the application program. They give data as input through 1M each
application program or get output data which is generated by
application programs.

b) Application programmers:
Application programmers are the users who write the application
programs. 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 level interactions which are understandable by storage
manager.
d) Specialized users:
These users are not traditional. They write some special application
programs which are not regular applications like 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.

5 Attempt any FOUR of the following: 16


(a) List and Explain the function of DBA. 4M
Note : Any 4 functions shall be considered.
Ans Functions of DBA : List 2M
1. Schema Definition
2. Storage Structure and Access Method Definition Explana
3. Assisting Application Programmers tion 2M
4. Physical Organization Modification
5. Approving Data Access

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
6. Monitoring Performance
7. Backup and Recovery
1. Schema Definition:
 The DBA definition the logical Schema of the database. A
Schema refers to the overall logical structure of the database.
 According to this schema, database will be developed to store
required data for an organization.
2. Storage Structure and Access Method Definition:
 The DBA decides how the data is to be represented in the
stored database.
3. Assisting Application Programmers:
 The DBA provides assistance to application programmers to
develop application programs.
4. Physical Organization Modification:
 The DBA modifies the physical organization of the database
to reflex the changing needs of the organization or to improve
performance.
5. Approving Data Access:
 The DBA determines which user needs access to which part
of the database.
 According to this, various types of authorizations are granted
to different users.
6. Monitoring Performance:
 The DBA monitors performance of the system. The DBA
ensures that better performance is maintained by making
changes in physical or logical schema if required.
7. Backup and Recovery:
 Database should not be lost or damaged.
 The DBA ensures this periodically backing up the database on
magnetic tapes or remote servers.
 In case of failure, such as virus attack database is recovered
from this backup.
(b) What is sequence? Explain with syntax and example. 4M
Ans Sequence is a set of integers 1, 2, 3, … that are generated and Definitio
supported by some database systems to produce unique values on n 2M
demand.
Syntax
 A sequence is a user defined schema bound object that generates
1M
a sequence of numeric values.
 Sequences are frequently used in many databases because many

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
applications require each row in a table to contain a unique value
and sequences provides an easy way to generate them.
 The sequence of numeric values is generated in an ascending or
descending order at defined intervals .
Syntax:
CREATE SEQUENCE sequence_name
START WITH initial_value
Example
INCREMENT BY increment_value 1M
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE ;
sequence_name: Name of the sequence.

initial_value: starting value from where the sequence starts.

increment_value: Value by which sequence will increment itself.


Increment_value can be positive or negative.

minimum_value: Minimum value of the sequence.


maximum_value: Maximum value of the sequence.

cycle: When sequence reaches its set_limit it starts from beginning.

nocycle: An exception will be thrown if sequence exceeds its


max_value.

Example
Following is the sequence query creating sequence in ascending
order.

Example :
CREATE SEQUENCE sequence_1
start with 1
increment by 1

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
minvalue 0
maxvalue 100
cycle;

(c) Explain with suitable example various types of triggers. 4M


Ans Triggers can be classified based on the following parameters.
Classification based on the timing Explana
 BEFORE Trigger: It fires before the specified event has occurred. tion of
 AFTER Trigger: It fires after the specified event has occurred. any two
 INSTEAD OF Trigger: A special type. You will learn more about types
the further topics. (only for DML ) with
suitable
Classification based on the level example
 STATEMENT level Trigger: It fires one time for the specified 2M each
event statement.
 ROW level Trigger: It fires for each record that got affected in the
specified event. (only for DML)

Classification based on the Event


 DML Trigger: It fires when the DML event is specified
(INSERT/UPDATE/DELETE)
 DDL Trigger: It fires when the DDL event is specified
(CREATE/ALTER

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Syntax Explanation:

 The above syntax shows the different optional statements that are
present in trigger creation.
 BEFORE/ AFTER will specify the event timings.
 INSERT/UPDATE/LOGON/CREATE/etc. will specify the event
for which the trigger needs to be fired.
 ON clause will specify on which object the above-mentioned event
is valid. For example, this will be the table name on which the
DML event may occur in the case of DML Trigger.
 Command "FOR EACH ROW" will specify the ROW level
trigger.
 WHEN clause will specify the additional condition in which the
trigger needs to fire.
 The declaration part, execution part, exception handling part is
same as that of the other PL/SQL blocks. Declaration part and
exception handling part are optional.

Example of DDL Trigger


1. create trigger saftey
2. on database
3. for
4. create_table,alter_table,drop_table
5. as
6. print'you can not create ,drop and alter table in this database'
7. rollback;

Example of DML trigger

1. create trigger deep


2. on emp
3. for
4. insert,update,delete
5. as
6. print'you can not insert,update and delete this table i'
7. rollback;

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

DML triggers are two type

AFTER Triggers

AFTER triggers are executed after the action of an INSERT,


UPDATE, or DELETE statement.

1. create trigger insert


2. on emp
3. after insert
4. as
5. begin
6. insert into empstatus values('active')
7. end

(d) What is cursor? Explain any two types of cursor. 4M


Ans. A cursor is a temporary work area created in the system memory
when a SQL statement is executed. A cursor contains information on Definitio
a select statement and the rows of data accessed by it. This temporary n 2M
work area is used to store the data retrieved from the database, and
manipulate this data. A cursor can hold more than one row, but can Explana
process only one row at a time. The set of rows the cursor holds is tion of
called the active set. types
2M
There are two types of cursors in PL/SQL
Implicit Cursors:
When DML statements like Delete, Insert, Update and Select
statements are executed, implicit statements are created to process
these statements. Oracle provides few attributes called as implicit
cursor attributes to check the status of DML operations. The cursor
attributes available are %FOUND, %NOTFOUND, %ROWCOUNT,
and %ISOPEN. The values of the cursor attributes always refer to the
most recently executed SQL statement.
Explicit Cursors:
When precise control is needed over query processing, cursor can be
explicitly declared in the declarative part of any PL/SQL block,
subprogram, or package. An explicit cursor is defined in the
declaration section of the PL/SQL Block. It is created on a SELECT

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
Statement which returns more than one row. A suitable name is
provided for the cursor.
(e) What is relational algebra? Explain select & project operations. 4M
Ans. Relational Algebra Operators are mathematical functions used to
retrieve queries by describing sequence operations on tables or even Definitio
databases (schema) involved. With relational algebra operators, a n 1M
query is always composed of a number of operators, which each in
turn are composed of relations as variables and return an individual Two
abstraction as the end product. operatio
ns 1½M
The following are the main relational algebra operators as applied to each
SQL

The SELECT Operator


The SELECT operator is used to choose a subset of the tuples(rows)
from a relation that satisfies a selection condition, acting as a filter to
retain only tuples that fulfills a qualifying requirement.
 The SELECT operator is relational algebra is denoted by the
symbol σ (sigma).
 The syntax for the SELECT statement is then as follows:
σ<Selection condition>(R)
 The σ would represent the SELECT command
 The <selection condition> would represent the condition for
selection.
 The (R) would represent the Relation or the Table from which
we are making a selection of the tuples.
To implement the SELECT statement in SQL, we consider an
example in which we would like to select the EMPLOYEE tuples
whose employee number is 7, or those whose date of birth is before
1980…
σempno=7(EMPLOYEE)
σdob<’01-Jan-1980′(EMPLOYEE)
The SQL implementation would translate into:
I. SELECT empno FROM EMPLOYEE WHERE empno=7
II. SELECT dob FROM EMPLOYEE WHERE DOB < ’01-Jan-
1980′

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

The PROJECT Operator


This operator is used to reorder, select and get rid of attributes from a
table. At some point we might want only certain attributes in a
relation and eliminate others from our query result. Therefore the
PROJECT operator would be used in such operations.

The symbol used for the PROJECT operation is π (pi).


 The general syntax for the PROJECT operator is:
π <attribute list>(R )
 π would represent the PROJECT.
 <attribute list> would represent the attributes(columns) we want
from a relational.
 (R ) would represent the relation or table we want to choose the
attributes from.
To implement the PROJECT statement in SQL, we consider an
example in which we would like to choose the Date of Birth (dob)
and Employee Number (empno) from the relation EMPLOYEE.
 πdob, empno(EMPLOYEE )

In SQL this would translate to:

SELECT dob, empno FROM EMPLOYEE


(f) What is use of group by clause? Explain with an example. 4M
Ans. The SQL GROUP BY clause is used in collaboration with the
SELECT statement to arrange identical data into groups.

The GROUP BY statement is often used with aggregate functions Definitio


(COUNT, MAX, MIN, SUM, AVG) to group the result-set by one or n
more columns. 2M
Explana
This GROUP BY clause follows the WHERE clause in a SELECT tion with
statement and precedes the ORDER BY clause. example
2M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

Syntax:
SELECT column_name(s)
FROM table_name
WHERE condition
GROUP BY column_name(s)
ORDER BY column_name(s);
Example
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
ORDER BY COUNT(CustomerID) DESC;

6 Attempt any FOUR of the following: 16


(a) What is data independence? What are its types? 4M
Ans Data Independence: Capacity to change the schema at one level of a
database system without having to change the schema at the next Definitio
higher level. n
A major objective for three-level architecture is to provide data 2M
independence, which means that upper levels are unaffected by
changes in lower levels. Any
There are two types of data independence: Two
 Logical data independence types
 Physical data independence 1M
each
Logical Data Independence
Logical data independence indicates that the conceptual schema can
be changed without affecting the existing external schemas. The
change would be absorbed by the mapping between the external and
conceptual levels.

Physical Data Independence


Physical data independence indicates that the physical storage
structures or devices could be changed without affecting conceptual
schema. The change would be absorbed by the mapping between the
conceptual and internal levels.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(b) Explain the need of normalization by example. 4M


Ans The need of normalization are the following:
 To Minimize data redundancy i.e. no unnecessarily duplication of Explana
data should be present. tion of
any 4
 To make database structure flexible i.e. it should be possible to needs
add new data values and rows without reorganizing the database 1M each
structure.
 Data should be consistent throughout the database i.e. it should not
suffer from following anomalies.
Insert Anomaly - Due to lack of data i.e., all the data available for
insertion such that null values in keys should be avoided. This kind of
anomaly can seriously damage a database
Update Anomaly - It is due to data redundancy i.e. multiple
occurrences of same values in a column. This can lead to inefficiency.
Deletion Anomaly - It leads to loss of data for rows that are not stored
elsewhere. It could result in loss of vital data.

• Complex queries required by the user should be easy to handle.


 To ensure data dependencies are logical (all related data items are
stored together).
(c) Draw and explain State diagram of transaction. 4M
Ans States of Transaction
A transaction must be in one of the following states: Diagram
2M
Active: the initial state, the transaction stays in this state while it is
executing. Explana
tion
Partially committed: after the final statement has been executed.
2M
Failed: when the normal execution can no longer proceed.

Aborted: after the transaction has been rolled back and the database
has been restored to its state prior to the start of the transaction.
Committed: after successful completion.

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

The state diagram corresponding to a transaction is shown in Figure.

A transaction has committed only if it has entered the committed


state. Similarly, a transaction has aborted only if it has entered the
aborted state. A transaction is said to have terminated if has either
committed or aborted.

A transaction starts in the active state. When it finishes its final


statement, it enters the partially committed state. At this point, the
transaction has completed its execution, but it is still possible that it
may have to be aborted, since the actual output may still be
temporarily hiding in main memory and thus a hardware failure may
preclude its successful completion.
(d) Explain tuple relational calculus with example. 4M
Ans The Tuple Relational Calculus: Explana
The tuple relational calculus is a nonprocedural language. We must tion
provide a formal description of the information desired. A query in 2M
the tuple relational calculus is expressed as

Example
2M

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332
i.e. the set of tuples for which predicate is true.

We also use the notation

to indicate the value of tuple on attribute .

o to show that tuple is in relation .

For example, to find the branch-name, loan number, customer name


and amount for loans over $1200:

(e) Compare functional dependency & multivalued dependency. 4M


Ans
Functional Dependencies Multivalued dependencies Any 4
This occurs when one attribute in This occurs when more than Points
a relation is unique one attributes are dependent on 1M each
another.

It is represented as X-->Y It is represented as X-->>Y

It plays a role in the 1NF It plays a role in the 4NF


database normalization. database normalization.

Example: Example:
Person->-> mobile,
EmpID -> EmpName,
Person ->-> food_likes
EmpName is functionally
dependent This is described as:
on EmpID because EmpName c person multi determines
an take only one value for the mobile” and “person multi
given value of EmpID determines food_likes.”

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

(f) Explain any four aggregate functions with example. 4M


Ans The following are the most commonly used SQL aggregate functions:

 AVG – calculates the average of a set of values. Any


 COUNT – counts rows in a specified table or view. four
 MIN – gets the minimum value in a set of values. function
 MAX – gets the maximum value in a set of values. s with
 SUM – calculates the sum of values. example
1M each
COUNT function example

To get the number of products in the products table,


the COUNT function is used as follows:

SELECT COUNT(*) FROM products;

AVG function example

To calculate the average units in stock of the products,


the AVG function is used as follows:

SELECT AVG(unitsinstock) FROM products;

Or

SELECT categoryid, AVG(unitsinstock) FROM products GROUP


BY categoryid;

SUM function example

To calculate the sum of units in stock by product category,


the SUM function is used with

the GROUP BY clause as the following query:

SELECT categoryid, SUM(unitsinstock)FROM products GROUP


BY categoryid;

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

WINTER – 2018 EXAMINATION


MODEL ANSWER
Subject: Relational Database Management System Subject Code: 17332

MIN function example

To get the minimum units in stock of products in the products table,


the MIN function is used as follows:

SELECT MIN(unitsinstock) FROM products;

MAX function example

To get the maximum units in stock of products in the products table,


the MAX function is used as shown in the following query:

SELECT MAX(unitsinstock)FROM products;

Page 32 / 32

You might also like