AL-502 DBMS Unit 5
AL-502 DBMS Unit 5
AL-502 DBMS Unit 5
Syllabus
UNIT V: Case Study of Relational Database Management Systems through
Oracle/PostgreSQL /MySQL: Architecture, physical files, memory structures, background
process. Data dictionary, dynamic performance view. Security, role management, privilege
management, profiles, invoker defined security model. SQL queries, Hierarchical quires,
inline queries, flashback queries. Introduction of ANSI SQL, Cursor management: nested and
parameterized cursors. Stored procedures, usage of parameters in procedures. User defined
functions their limitations. Triggers, mutating errors, instead of triggers.
Advanced locking
Concurrency MVCC MVCC
mechanisms
Extensibility Limited High Moderate
Rich (LOBs, XML, Extensive (JSONB, Limited (JSON support via
Data Types
JSON) arrays) plugin)
High for complex High for analytical
Performance High for simple workloads
queries workloads
Excellent (RAC, Data Good (sharding,
Scalability Good (replication)
Guard) replication)
Summary of Insights
Oracle: Ideal for large-scale, mission-critical applications requiring robust
performance and advanced analytics.
PostgreSQL: Suited for complex applications requiring customization and standards
compliance.
MySQL: Best for lightweight, read-heavy applications with simple requirements, like
web apps.
Architecture, Physical Files, Memory Structures, and Background Processes in RDBMS
1. General RDBMS Architecture
An RDBMS architecture generally consists of:
Client Layer: Interfaces like applications or tools for users to query and interact.
Server Layer: The database engine that processes queries, manages transactions, and
stores data.
Storage Layer: Physical files where the data resides
Physical Files in RDBMS
RDBMS stores data in structured physical files on disk.
Data Files: Store actual database data in tables.
Redo Logs: Record changes for recovery in case of failure.
SQL Queries
Hierarchical Queries
SQL Example:
sql
A subquery defined within the main query, typically in the SELECT or FROM clause.
SQL Example:
sql
SQL Example:
sql
Summary Table
Concept Description
INSERT INTO employees (id, name, salary) VALUES (1, 'John Doe', 5000);
3. DCL (Data Control Language):
o Controls access to data.
o Commands: GRANT, REVOKE.
sql
BEGIN;
UPDATE employees SET salary = salary + 500 WHERE id = 1;
COMMIT;
5. SQL Extensions: While ANSI SQL provides the foundation, most RDBMS systems
extend it with proprietary features.
Cursor Management
What is a Cursor?
A cursor is a database object used to retrieve, manipulate, and navigate through rows in a
query result set sequentially.
Types of Cursors
1. Implicit Cursors: Automatically created by the database for single-row queries.
2. Explicit Cursors: Defined by users to handle multi-row queries.
Nested Cursors
Nested cursors are cursors defined and used inside another cursor. They allow processing
complex multi-level query results.
Example:
Sql
OPEN outer_cursor;
FETCH NEXT FROM outer_cursor INTO @dept_id;
WHILE @@FETCH_STATUS = 0
BEGIN
OPEN inner_cursor FOR SELECT employee_id FROM employees WHERE
department_id = @dept_id;
FETCH NEXT FROM inner_cursor INTO @emp_id;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @emp_id; -- Process the employee ID
FETCH NEXT FROM inner_cursor INTO @emp_id;
END;
CLOSE inner_cursor;
FETCH NEXT FROM outer_cursor INTO @dept_id;
END;
CLOSE outer_cursor;
WHILE @FETCH_STATUS = 0
BEGIN
PRINT @emp_id + ' ' + @emp_name;
FETCH NEXT FROM employee_cursor INTO @emp_id, @emp_name;
END;
CLOSE employee_cursor;
Key Points
1. ANSI SQL ensures cross-platform compatibility and standardization.
2. Cursors provide controlled access to query results, especially useful in procedural
logic.
3. Nested and Parameterized Cursors handle complex scenarios like multi-level
queries and dynamic data retrieval.
Stored Procedures
Triggers
What is a Trigger?
A trigger is a stored procedure that automatically executes in response to certain events on a
table or view, such as INSERT, UPDATE, or DELETE. Triggers are typically used for
enforcing business rules, auditing, and preventing invalid transactions.
Example of a Trigger:
sql
INSTEAD OF Customizes the actions for DML operations on views or tables. Executes
Triggers instead of the default action.