0% found this document useful (0 votes)
38 views20 pages

C16-DBMS Key

DBMS Paper Key C16 Batch

Uploaded by

TSN Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views20 pages

C16-DBMS Key

DBMS Paper Key C16 Batch

Uploaded by

TSN Prasad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

BOARD DIPLOMA EXAMINATION, (C-16)

MARCH/APRIL-2024

DCME-THIRD SEMESTER EXAMINATION

Time: 3 Hours Total Marks: 80

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

Q1. Define instances and schemas.


Ans : 3 || Marks

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

Q4. Write the benefits of SQL


Ans : 3| Marks
The benefits of SQL are SQL is English like language Easy to learn SQL is non
procedural language. SQL specifies what is required and not how it should be done
More productivity. With a single statement we can perform task like creation of
table etc. SQL operations are performed at a set level. One select statement can
retrieve multiple rows, one modify statement can modify multiple rows. More
powerful than record at a time processing languages like COBOL. Application
portability Cross system communication SQL standard exists. All RDBMS support
SQL. Both interactive and embedded access. Can be used by specialist and non-
specialist SQL programming is done at the logical level; there is little need to deal
with the details of implementation. SQL provides automatic navigation to data.

Q5. Write about pseudo-columns.


Ans : 3| Marks
Pseudocolumn: A pseudo-column behaves like a table column but is not actually stored
in the table. You can select from pseudo-columns, but you cannot insert, update, or
delete their values. A pseudo-column is also similar to a function without arguments.

3|Page
CURRVAL and NEXTVAL
LEVEL
ROWID
ROWNUM.

Q6. List any six character functions in SQL.


Ans : 3| Marks
a) LOWER
b) UPPER
c) INITCAP
d) LENGTH
e) INSTR
f) INSTR
g) SUBSTR
h) LTRIM
i) RTRIM

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;

Q8. Define CAP theorem


Ans : 3| Marks
The three letters in CAP refer to three desirable properties of distributed systems with
replicated data: consistency (among replicated copies), availability (of the system for
read and write operations) and partition tolerance (in the face of the nodes in the system
being partitioned by a network fault).
The CAP theorem states that it is not possible to guarantee all three of the desirable
properties – consistency, availability, and partition tolerance at the same time in a
distributed system with data replication

Q9. List the advantages of Mongo DB


Ans : 3| Marks
MongoDB has many advantages which makes it popular and highly demanded.
Schema Not Required
Structure of a single object is clear.
No complex joins.
Deep query-ability.
Tuning.
Ease of scale-out
Uses internal memory for storing the (windowed) working set, enabling faster access of
data.
Q10. Write the syntax to insert the document in Mongo DB.

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.

Q11 Explain overall DBMS structure with a diagram.


Ans : 5 | Marks

.
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

The mapping cardinality can be one of the following


One-to-one: An entity in A is associated with at most one entity in B, and an entity in B

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

Many-to-one: An entity in A is associated with at most one entity in


B. entity in B is associated with any number in A.
E.g:- Goods Vendor Books Publisher
Many-to-many: Entities in A and B are associated with any number from each other.
An entity in X is associated with any number of entities in B and an entity in Y is
associated with any number of entities in A.
E.g:- Students Hobbies

11 | P a g e
The appropriate mapping cardinality for a particular relationship set depends on the real
world being modeled.

Q13. Explain data types in SQL


Ans : 5 | Marks
Data Types: Each literal/column has a data type.

⮚ 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’

Where ‘p’ is the precision and ‘s’ is the


Maximum precision scale. E.g. number (7, 2) is a number that
Number(p,s)
is 38 digits has 2 digits after decimal and total of 7
digits.
Long Up to 2GB Character data of variable length
A date between jan-
Date 1-4712 BC to dec- e.g. ’18-jul-2012’
31-4712 AD
Maximum size is Raw binary data of maximum size 255
Raw(size)
255 bytes bytes is accepted
Raw binary data of variable length up to
Long Raw Up to 2GB
2GB
Hexadecimal string representing the
unique address of a row in its table. This
ROWID
data type is primarily for values returned by
the ROWID pseudo column.
Integer represents a signed integer,
Integer
decimal or binary

13 | P a g e
Represents float point number p
Float(p) represents number of precision for
decimal point

Q14(a). 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

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;

Q14(b). Explain the architecture of PL/SQL


Ans : 5 | Marks
PL/SQL is a block-structured language, meaning that PL/SQL programs are divided
and written in logical blocks of code.
PL/SQL BLOCK STRUCTURE

[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:

The PL/SQL is a technology, not an independent product. It is an integrated part of


Oracle. It has
own processing engine that executes PL/SQL blocks and subprograms.

The engine can be installed in an oracle server or in an application development tool


such as Oracle Forms or Oracle Reports.
So, PL/SQL can reside in two environments:
1.The Oracle Server
2.Oracle Tools

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;

Q16(a). Write a PL/SQL program to display N numbers using for loop


Ans : 2.5| Marks
DECLARE
n NUMBER := 10; -- You can change this value to display more or fewer numbers
BEGIN
FOR i IN 1..n LOOP
DBMS_OUTPUT.PUT_LINE('Number ' || i || ': ' || i);
END LOOP;
END;
/
Output:
Number 1: 1
Number 2: 2
Number 3: 3
Number 4: 4
Number 5: 5
Number 6: 6
Number 7: 7
Number 8: 8
Number 9: 9
Number 10: 10

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.

o NOSQL improve the programmer productivity by using a database that better


matches an application needs.
o Improve data access performance via some combination of handling larger data
volumes. It also reduce latency (amount of time taken to give data).

***

20 | P a g e

You might also like