C16-DBMS Key
C16-DBMS Key
MARCH/APRIL-2024
PART - A
Instructions 10Q x 3M = 30M
(1) Answer all questions
(2) Each question carries three marks
(3) Answers should be brief and straight to the point and shall not exceed
five simple sentences
Databases change over time as information is inserted and deleted. The information
present in the database does not remain constant over a period of time. Instance: The
collection of information stored in the database at a particular moment is called an
instance of the database The actual content of the database at a point in time Schema:
The overall design of the database is called the database schema The logical structure
of the database An analogy can be made with the programming language notion: Data
type definition – schema Value of a variable – instance There are several schemas,
corresponding to levels of abstraction: Physical Schema (Lowest level) Logical Schema
(Intermediate level) Sub schema (Highest level)
1|Page
Q2. Define an entity and entity set.?
Ans : 3 || Marks
Entity: An entity is a thing or object in the real world that is distinguishable from other
objects.
Example:
Entity -set: An entity set is a set of entities of the same type that share the same
properties or attributes
Example:
2|Page
Q3. List the database users..
Ans : 3| Marks
o Application Programmers:
o Sophisticated Users
o Specialized Users
o Unsophisticated Users or Naive Users
3|Page
CURRVAL and NEXTVAL
LEVEL
ROWID
ROWNUM.
Q7. Write a PL/SQL program to find whether given number is odd or even.
Ans : 3| Marks
declare
n number:=&n;
begin
if mod(n,2)=0
then
dbms_output.put_line('number is even');
else
4|Page
dbms_output.put_line('number is odd');
end if;
end;
5|Page
Ans : 3| Marks
The insert() method in MongoDB inserts documents in the MongoDB collection.
This method is also used to create a new collection by inserting documents.
Syantax:
db.Collection_name.insert(
<document or [document1, document2,...]>,
{
writeConcern: <document>,
ordered: <boolean>
})
6|Page
PART - B
Instructions 5Q x 10M = 50M
(1) Answer any five questions
(2) Each question carries ten marks
(3) Answers should be comprehensive and criterion for valuation is the
content but not the length of the answer.
.
A database system is partitioned into modules that deal with each of the
7|Page
responsibilities of the overall system.
The functional components of a database system
o Query Processor Components
o Storage manager Components
o Query Processor Components
o DML Compiler
o Embedded DML pre-compiler
o DDL interpreter
o Query evaluation engine
DML Compiler
Translates DML statements in a query language into low-level instructions
Embedded DML pre-compiler Which converts DML statements embedded in an
application program to normal procedure calls in the host language Pre-compiler
must interact with the DML compiler to generate the appropriate code
DDL interpreter
Which interprets DDL statements and records them in a set of tables containing
metadata
Query evaluation engine
Which executes low-level instructions generated by the DML compiler Storage
manager components
Storage manager components provides the interface between
Low level data stored in the database
Application programs • Queries submitted to the system
Components of storage manager:
Authorization and integrity manager
8|Page
Transaction manager
File manager
Buffer manager
Authorization and integrity manager
Which tests for the satisfaction of integrity constraints and checks the authority of
users to access data
Transaction manager
Which ensures that the database remains in a consistent state despite system
failures Concurrent transaction executions proceed without conflicting
File manager
Which manages the allocation of space on disk storage Manages data structures
used to represent information stored on the disk
Buffer manager
Which is responsible for fetching data from disk storage into memory Deciding
what data to cache in memory Data structures in system structure Data files: it
stores the database itself Data dictionary A file stores a set of tables Result of
compilation of number of DDL statements DDL compiler generates a set of tables
stored in a data dictionary Data dictionary contains metadata Meta data means data
about data Indices: Provide fast access to data items that hold particular values
Statistical data: store statistical information about the data in the database
9|Page
12. Explain mapping constraints.
Ans : 5 | Marks
Mapping: A mathematical relation such that each element of a given set is associated
with an element of another set.Constraint: A constraint is a restriction on the degree of
freedom you have in preceding a solution.
Mapping Constraints: An entity relations
hip enterprise schema can define certain constraints called mapping constraints. The
most important types of mapping constraints are
Mapping Cardinalities
Existence dependencies
Mapping Cardinalities:
Mapping cardinalities are most useful for describing binary relationship-sets which
involve two entity sets Mapping cardinalities express the number of entities to which
another entity can be associated via a relationship set
10 | P a g e
is associated with at most one entity in A.
E.g:- Husband Wife
Student Pin no
One-to-many: An entity in A is associated with any number in
B. An entity in B is associated with at most one entity in A. E.g:- Father
Children
Class Students
11 | P a g e
The appropriate mapping cardinality for a particular relationship set depends on the real
world being modeled.
⮚ The data types are used to specify the type of the data that will be stored in
each column of the table. The following table lists the typical data types used in
Oracle 8i/9i.
Data type SIZE Description
Fixed length character data of length size
bytes. E.g. if the width of a character
Char(size) Up to 2000 bytes column is 8 and the string stored it in is
‘RDBMS’, it will be stored as ‘RDBMS_ _
_’
12 | P a g e
Where size is the number of characters to
store. It accepts variable length strings
Varchar2(siz e.g. if the width of a varchar column is 8
Up to 4000 bytes
e) and the string ‘RDBMS’ is stored as
‘RDBMS’
13 | P a g e
Represents float point number p
Float(p) represents number of precision for
decimal point
14 | P a g e
f := x * fact(x-1);
END IF;
RETURN f;
END;
BEGIN
num:= 5;
factorial := fact(num);
dbms_output.put_line(' Factorial '|| num || ' is ' || factorial);
END;
[DECLARE]
Declaration statements;
BEGIN
Execution statements; [EXCEPTION]
Exception handling statements; END;
/
1. DECLARATION SECTION:
This section starts with the keyword DECLARE. It is an optional section and defines
all variables, cursors, subprograms, and other elements to be used in the program.
EXECUTABLE COMMANDS
15 | P a g e
This section is enclosed between the keywords BEGIN and END and it is a mandatory
section. It consists of the executable PL/SQL statements of the program. It should have
at least one executable line of code, which may be just a NULL command to indicate
that nothing should be executed.
EXCEPTION HANDLING
This section starts with the keyword EXCEPTION. This section is again optional and
contains exception(s) that handle errors in the program.
ARCHITECTURE OF PL/SQL:
16 | P a g e
The PL/SQL processing an anonymous block. The engine executes procedural
Statements. But sends SQL statements to the SQL statement Executor in the Oracle
Server.
17 | P a g e
Q15. Explain Recursion with an example
Ans : 5| Marks
In PL/SQL functions can call themselves .A function is recursive if a statement in the
body of the function calls itself. Sometimes called circular definition, recursion is the
process of defining something in terms of itself.
Each recursive call creates a new instance of any items declared in the sub program,
including parameters, variables and exceptions.
The main advantage of recursion is clear, short and simple program.
A commonly used example of a recursion is determining the factorial of a number!
=n*(n-1)!
EXAMPLE:
DECLARE
num number;
factorial number;
FUNCTION fact(x number) RETURN number IS
f number;
BEGIN
IF x=0 THEN
f := 1;
ELSE
f := x * fact(x-1);
END IF;
RETURN f;
END;
BEGIN
num:= 5;
18 | P a g e
factorial := fact(num);
dbms_output.put_line(' Factorial '|| num || ' is ' || factorial);
END;
19 | P a g e
Q16(b). Explain the need for NoSQL
Ans : 2.5| Marks
o When compares to relational databases, NOSQL databases are more scalable and
provide superior performance.
o Application developers have been frustrated with impedance mismatch between
the relational data structures and in memory data structures of the applications.
Using NOSQL databases allows developer to develop without having to convert
in memory structures.
o Rise of the web as a platform also created a major factor change in data storage
as the need to support large volumes of data by running on clusters.
o RDBMS is not designed to run efficiency on clusters.
***
20 | P a g e