0% found this document useful (0 votes)
4 views7 pages

Unit 5 Dbms

A distributed database system stores data across multiple locations, appearing as a single database to users, while a centralized database system stores all data at one location. Key differences include data location, performance, reliability, and scalability. Uses of distributed systems include banking, e-commerce, and telecommunications, while topics such as data warehousing, OODBMS, concurrency control, and triggers are also discussed.

Uploaded by

harshitpal00004
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)
4 views7 pages

Unit 5 Dbms

A distributed database system stores data across multiple locations, appearing as a single database to users, while a centralized database system stores all data at one location. Key differences include data location, performance, reliability, and scalability. Uses of distributed systems include banking, e-commerce, and telecommunications, while topics such as data warehousing, OODBMS, concurrency control, and triggers are also discussed.

Uploaded by

harshitpal00004
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

Q.1 What is distributed database system?

How it is different from the


centralized database system? Give the use of -distributed system.

Distributed Database System

A distributed database system is a database in which data is stored at multiple locations (sites)
that are connected through a network.
Even though the data is spread across different computers, it appears as a single database to
the user.
The system is managed by a Distributed Database Management System (DDBMS).

Example: A bank where customer data is stored at different branch servers but can be accessed
from any branch.

Centralized Database System

A centralized database system stores the entire database at one single location (one server).
All users access the database through this central server.

Example: A small organization storing all employee data on one main server.

Difference between Distributed and Centralized Database System

Centralized Database
Feature Distributed Database System
System
Data location Data is stored at multiple sites Data is stored at one site
Network
Uses network to connect sites Network not essential
dependency
Slower when many users
Performance Faster for local users
access
High (failure of one site doesn’t stop
Reliability Low (single point of failure)
system)
Scalability Easy to expand by adding new sites Difficult to expand
Data availability High availability Limited availability
Cost Higher setup and maintenance cost Lower cost
Uses of Distributed Database System

1. Banking systems – Each branch manages local data while sharing common customer
data.
2. E-commerce platforms – Data is stored at different locations to serve users faster.
3. Airline reservation systems – Flight data is distributed across multiple airports.
4. Telecommunication systems – Call records and customer data are stored at multiple
centers.
5. Large organizations – Different departments manage their own data while sharing
important information.

Q.2
Write notes
a) Data Warehousing
b) OODBMS
c) Concurrency Control
d) Flashback Queries

a) Data Warehousing

Data Warehousing is the process of collecting data from different sources and storing it in a
central place for analysis and decision making.
It is mainly used for reporting, trend analysis, and business intelligence, not for daily
transactions.
A data warehouse stores historical data and is designed to support management decisions.

Key features:

 Subject-oriented (organized by topics like sales, customers)


 Integrated (data from multiple sources)
 Time-variant (stores past data)
 Non-volatile (data is not frequently changed)

b) OODBMS (Object-Oriented Database Management System)

An OODBMS stores data as objects, just like in object-oriented programming.


Each object contains data and methods together.
It supports concepts such as classes, inheritance, and encapsulation, making it suitable for
complex data.

Uses:

 Multimedia systems
 CAD/CAM applications
 Scientific and engineering databases

c) Concurrency Control

Concurrency Control is a technique used in DBMS to manage simultaneous access to the


database by multiple users.
Its main goal is to ensure data consistency and correctness when many transactions are running
at the same time.
It prevents problems like lost updates, dirty reads, and inconsistent data.

Common methods:

 Lock-based protocols
 Timestamp-based protocols
 Optimistic concurrency control

d) Flashback Queries

Flashback Queries allow users to see old data from the database without restoring backups.
Using this feature, data can be viewed as it existed at a specific time or point in the past.
It is useful for recovering accidental changes and for auditing purposes.

ii) Triggers

A Trigger is a special type of database program that automatically runs when a specific event
occurs on a table.
These events are usually INSERT, UPDATE, or DELETE operations.
Triggers help maintain data integrity and enforce business rules.

Uses of triggers:

 Automatically update another table


 Keep audit records
 Prevent invalid data entry
What is Cursor Management? Explain nested and
parameterized cursors.
Cursor Management

Cursor Management is a technique used in DBMS (especially in PL/SQL) to control and


process query results row by row.
When a SQL query returns more than one row, a cursor is used to point to one row at a time so
that each row can be processed individually.

Cursor management includes:

 Declaring the cursor


 Opening the cursor
 Fetching data from the cursor
 Closing the cursor

Nested Cursors

A Nested Cursor is a cursor used inside another cursor.


The outer cursor processes one set of rows, and for each row of the outer cursor, the inner cursor
is executed.

Use:
Nested cursors are used when related data from multiple tables needs to be processed in a
parent–child manner.

Example (concept):
For each department (outer cursor), fetch all employees of that department (inner cursor).

Parameterized Cursors

A Parameterized Cursor is a cursor that accepts input values (parameters) at the time of
opening it.
These parameters help fetch different result sets using the same cursor definition.

Use:
Parameterized cursors are useful when the same query logic is required for different input
values, such as department number or salary range.
i) Oracle Exception Handling Mechanism ii) Branching and looping
Constructs in ANSI SQL..
i) Oracle Exception Handling Mechanism

Exception handling in Oracle is used to handle runtime errors that occur during the execution
of a PL/SQL program.
Instead of stopping the program suddenly, exception handling allows the program to respond
gracefully to errors.

In Oracle, exceptions are handled using the EXCEPTION block, which is written after the
executable statements.

Types of exceptions:

 Predefined exceptions – Built-in errors like NO_DATA_FOUND, TOO_MANY_ROWS.


 User-defined exceptions – Errors defined by the programmer for specific conditions.
 Others (WHEN OTHERS) – Handles all unhandled exceptions.

Benefits:

 Prevents program crash


 Provides meaningful error messages
 Improves program reliability

ii) Branching and Looping Constructs in ANSI SQL

Branching constructs allow SQL to make decisions based on conditions.


They control which statements are executed.

Branching examples:

 CASE statement – Used to apply conditions inside SQL queries.


 IF–THEN–ELSE – Used in SQL procedural extensions (like PL/SQL).

Looping constructs are used to repeat a set of statements until a condition is satisfied.
ANSI SQL supports looping mainly through procedural extensions.

Looping examples:

 WHILE loop
 FOR loop
 LOOP … EXIT WHEN
Uses:

 Repeated data processing


 Applying logic to multiple rows
 Automating tasks in database programs

Explain triggers and assertions and explain it with through


appropriate query.
Triggers

A Trigger is a special database program that automatically executes when a specific event
occurs on a table.
These events are usually INSERT, UPDATE, or DELETE operations.
Triggers are mainly used to maintain data integrity, enforce business rules, and keep audit
records.

Types of Triggers

 BEFORE trigger – Executes before the operation


 AFTER trigger – Executes after the operation
 INSTEAD OF trigger – Used with views

Example: Trigger to prevent inserting negative salary

CREATE OR REPLACE TRIGGER check_salary


BEFORE INSERT OR UPDATE ON employee
FOR EACH ROW
BEGIN
IF :[Link] < 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Salary cannot be negative');
END IF;
END;
/
Explanation:
This trigger checks salary before inserting or updating a record.
If salary is negative, the operation is stopped with an error message.

Assertions

An Assertion is a condition that must always be true in the database.


It is used to define global constraints that involve one or more tables.
Assertions help ensure overall data correctness.
Note: Assertions are part of SQL standard but are not directly supported in Oracle. They are
mainly theoretical and implemented using triggers in practice.

Example: Assertion to ensure total students ≤ 100

CREATE ASSERTION student_limit


CHECK (
(SELECT COUNT(*) FROM student) <= 100
);
Explanation:
This assertion ensures that the total number of records in the student table never exceeds 100.
If the condition becomes false, the database rejects the operation.

Difference Between Trigger and Assertion

Trigger Assertion
Activated by events (INSERT, UPDATE, DELETE) Always checked
Table-specific Database-wide
Supported in Oracle Not supported in Oracle
Procedural Declarative

You might also like