0% found this document useful (0 votes)
2 views9 pages

Google Keep Document

The document outlines important questions related to Relational Database Management Systems (RDBMS), covering topics such as definitions, advantages, transaction states, locking mechanisms, and PL/SQL programming constructs. It includes explanations of concepts like cursors, exception handling, procedures, functions, triggers, and various types of schedules. Additionally, it highlights differences between DBMS and RDBMS, as well as methods to prevent deadlocks.

Uploaded by

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

Google Keep Document

The document outlines important questions related to Relational Database Management Systems (RDBMS), covering topics such as definitions, advantages, transaction states, locking mechanisms, and PL/SQL programming constructs. It includes explanations of concepts like cursors, exception handling, procedures, functions, triggers, and various types of schedules. Additionally, it highlights differences between DBMS and RDBMS, as well as methods to prevent deadlocks.

Uploaded by

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

RDBMS IMPORTANT QUESTIONS

2 MARKS

1) What is RDBMS? Explain Advantages.

RDBMS stands for Relational Database Management System.


It is a type of database management system (DBMS) that stores data in the form of tables.

Advantages of RDBMS:

1. Data Integrity
2. Data Redundancy
3. Data Security
4. Data Independence
5. Query Capability

2) Explain States of Transaction

A transaction in a database is a sequence of operations performed as a single logical unit of


work. It must satisfy ACID properties.
States of a Transaction:

1. Active State
2. Partially Committed
3. Committed
4. Failed
5. Aborted

3) Define:

1. Growing Phase:

Part of the Two-Phase Locking (2PL) protocol.

In this phase, a transaction acquires all the locks it needs.

No lock is released in this phase.

2. Shrinking Phase:

Begins once the transaction releases its first lock.

In this phase, no new locks can be acquired.

4) Explain Read(Q) and Write(Q)

Read(Q):
This operation reads the value of data item Q from the database and stores it in a local variable
(in memory) used by the transaction.
Does not change the data in the database.

Write(Q):
This operation writes the value of data item Q from the local variable back to the database.
Modifies the actual data in the database.

5) What is Cursor? Explain Types of Cursor

A cursor is a pointer or handle used to process and retrieve rows from a result set one at a time
in PL/SQL.

Types of Cursors:

1. Implicit Cursor
2. Explicit Cursor
3. Cursor FOR Loop
4. Parameterized Cursor

6) Explain Lock and Compatibility Function


Lock:

A lock is a mechanism to control concurrent access to data in a database to ensure data


consistency.

Types of Locks:

Shared Lock (S): Allows multiple transactions to read, but not write.

Exclusive Lock (X): Allows a transaction to both read and write. No other transaction can read or
write the data item.

Compatibility Function (Lock Compatibility Matrix):

If two transactions hold shared locks, both can read.

If any transaction wants an exclusive lock, no other lock is allowed.

7) Explain %TYPE and %ROWTYPE

These are PL/SQL attributes used to declare variables with the same datatype as a table
column or row.

%TYPE:
Declares a variable with the same data type as a table column.

salary employee.salary%TYPE;
%ROWTYPE:
Declares a record that represents a full row of a table.

emp_record employee%ROWTYPE;

8) Explain Properties of Transaction

A transaction in a database is a sequence of operations performed as a single logical unit of


work. To ensure data integrity and consistency, every transaction must follow ACID properties:

1. Atomicity
2. Consistency
3. Isolation
4. Durability

9) Define:

1. Upgrading (Lock Upgrading):

When a transaction changes a shared lock to an exclusive lock.

Required when a transaction initially reads a data item but later needs to write .

2. Downgrading (Lock Downgrading):

When a transaction changes an exclusive lock to a shared lock.

Rarely used; done when transaction no longer needs to write but still needs to read.

10) What is Schedule? List types of schedules.

In RDBMS (Relational Database Management System), a Schedule is the chronological order in


which instructions of concurrent transactions are executed.

Types of Schedules:

1. Serial Schedule:
2. Concurrent (Non-Serial) Schedule
3. Conflict-Serializable Schedule
4. View-Serializable Schedule
5. Cascadeless Schedule
6. Strict Schedule
7. Recoverable Schedule

11) Explain Cursor Attributes:

In PL/SQL (Oracle) and similar systems, cursors are used to retrieve and process query result
rows one at a time. Cursor attributes provide status information about the cursor during or after
its operation.

Here are the four main cursor attributes:


1. %FOUND
2. %NOTFOUND
3. %ISOPEN
4. %ROWCOUNT

12) What is a Lock? Explain Types of Lock.

What is a Lock?

In RDBMS, a lock is a mechanism used to control access to data in a multi-user environment. It


ensures data consistency, isolation, and prevents conflicts when multiple users try to read/write
the same data at the same time.

Types of Locks:

1. Shared Lock (Read Lock)

Allows multiple users to read a resource simultaneously.

No user can write while a shared lock is in place.

Used when SELECT queries are executed.

2. Exclusive Lock (Write Lock)

Only one transaction can access the data.

Other transactions are blocked from reading or writing.

Based on Level of Locking:

3. Row-Level Lock

Locks only the specific row being accessed.

Provides high concurrency.

Efficient for systems with many users.

4. Table-Level Lock

Locks the entire table.

Prevents other users from accessing any row in the table.


4 Marks

1) What is Exception Handling? Explain Types of Exceptions.

Exception Handling in PL/SQL is used to manage runtime errors so the program can continue or
exit gracefully.

Types of Exceptions:

1. Predefined Exceptions – Built-in by PL/SQL (e.g., NO_DATA_FOUND, ZERO_DIVIDE).

2. User-Defined Exceptions – Declared explicitly by the programmer.

3. Unnamed System Exceptions – Not predefined but raised automatically (can be caught using
OTHERS).

---

2) Difference between DBMS and RDBMS

DBMS RDBMS

Stores data in files or collections Stores data in tables (relations)


No relationship between data Maintains relationships via foreign keys
Does not support normalization Supports normalization
Example: File system, XML DB Example: MySQL, Oracle, SQL Server

---

3) What is Procedure? Write Syntax and Example.

A Procedure is a named PL/SQL block that performs a task and may or may not return values.

Syntax:

CREATE OR REPLACE PROCEDURE proc_name


IS
BEGIN
-- Statements
END;

Example:

CREATE OR REPLACE PROCEDURE greet_user


IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello, User!');
END;

---

4) What is PL/SQL? Explain PL/SQL Block with Example.

PL/SQL (Procedural Language/SQL) is Oracle’s extension of SQL with procedural features like
loops, conditions, and error handling.

Structure of PL/SQL Block:

DECLARE
-- Declarations
BEGIN
-- Executable statements
EXCEPTION
-- Error handling
END;

Example:

DECLARE
v_num NUMBER := 10;
BEGIN
DBMS_OUTPUT.PUT_LINE('Value: ' || v_num);
END;

---

5) What is Deadlock? Explain Methods to Prevent Deadlock.

Deadlock occurs when two or more transactions wait indefinitely for each other to release locks.

Prevention Methods:

1. Timeouts – Abort transactions after waiting too long.

2. Lock Ordering – Ensure all transactions acquire locks in a fixed order.

3. Avoid Holding Locks Too Long – Release locks as soon as possible.

4. Deadlock Detection Algorithms – Periodically check for deadlocks and resolve.

---

6) Explain Recoverable and Cascadeless Schedule with Example.


Recoverable Schedule: Transactions commit only after the transaction they depend on commits.

Example: T2 reads from T1, and T2 commits after T1.

Cascadeless Schedule: Transactions do not read uncommitted data.

Example: T2 waits to read from T1 only after T1 commits, preventing cascading rollback.

---

7) What is Function? Write Syntax and Example.

A Function is a PL/SQL block that performs a task and returns a value.

Syntax:

CREATE OR REPLACE FUNCTION func_name


RETURN datatype
IS
BEGIN
-- Statements
RETURN value;
END;

Example:

CREATE OR REPLACE FUNCTION square(n NUMBER)


RETURN NUMBER
IS
BEGIN
RETURN n * n;
END;

---

8) What is Exception Handling? Explain 4 Predefined Exceptions.

Exception Handling deals with runtime errors in PL/SQL.

Four Predefined Exceptions:

1. NO_DATA_FOUND – No rows returned from a query.

2. ZERO_DIVIDE – Division by zero error.

3. TOO_MANY_ROWS – Query returns more than one row.


4. INVALID_NUMBER – Conversion from string to number failed.

---

9) What is Trigger? Explain Types of Trigger.

A Trigger is a stored PL/SQL block that automatically executes in response to DML operations
(INSERT, UPDATE, DELETE).

Types of Triggers:

1. Row-level Trigger – Executes for each row affected.

2. Statement-level Trigger – Executes once per statement.

3. BEFORE Trigger – Executes before the DML action.

4. AFTER Trigger – Executes after the DML action.

---

10) Explain Looping Statements in PL/SQL with Example.

PL/SQL supports three types of loops:

1. Basic LOOP

2. WHILE LOOP

3. FOR LOOP

Example – FOR LOOP:

BEGIN
FOR i IN 1..5 LOOP
DBMS_OUTPUT.PUT_LINE('Count: ' || i);
END LOOP;
END;

---

11) Explain Conditional Statements in PL/SQL with Example.

PL/SQL provides IF statements for decision-making.


Syntax:

IF condition THEN
-- statements
ELSIF condition THEN
-- statements
ELSE
-- statements
END IF;

Example:

DECLARE
marks NUMBER := 75;
BEGIN
IF marks >= 90 THEN
DBMS_OUTPUT.PUT_LINE('Grade: A');
ELSIF marks >= 60 THEN
DBMS_OUTPUT.PUT_LINE('Grade: B');
ELSE
DBMS_OUTPUT.PUT_LINE('Grade: C');
END IF;
END;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy