Professional Documents
Culture Documents
Database
Management
System
UNIT-I [10h]
Overview of Databases: Database concepts, DBMS, Data Base System Architecture (Three
Level ANSI-SPARC Architecture), Advantages and Disadvantages of DBMS, Data Independence,
DBA and Responsibilities of DBA, Relational Data Structure, Keys, Relations, Attributes, Schema and
Instances, Referential integrity, Entity integrity.
Data Models: Relational Model, Network Model, Hierarchical Model, ER Model: Design,
issues, Mapping constraints, ER diagram, Comparison of Models.
UNIT-II [10h]
Functional dependencies and Normalization: Functional dependencies, Decomposition, Full
Functional Dependency (FFD), Transitive Dependency (TD), Join Dependency (JD), Multi-valued
Dependency (MVD), Normal Forms (1NF, 2NF, 3NF, BCNF), De-normalization.
Database Security: Introduction, Threats, Counter Measures.
Control Structures: Introduction to conditional control, Iterative control and sequential control
statements, Cursors, Views.
2
University Institute of Engineering (UIE)
Department
Department of Computer
of Computer Scienceand
Science andEngineering
Engineering (CSE)
(CSE)
UNIT-III [10h]
Package, Procedures and Triggers: Parts of procedures, Parameter modes, Advantages of
procedures, Syntax for creating triggers, Types of triggers, package specification and package body,
developing a package, Bodiless package, Advantages of packages.
Transaction Management and Concurrency Control: Introduction to Transaction Processing,
Properties of Transactions, Serializability and Recoverability, Need for Concurrency Control, Locking
Techniques, Time Stamping Methods, Optimistic Techniques and Granularity of Data items.
Database Recovery of database: Introduction, Need for Recovery, Types of errors, Recovery
Techniques.
3
University Institute of Engineering (UIE)
Department of Computer Science and Engineering (CSE)
Chapter 2.3
(Control Structures)
Control Structures: Introduction to conditional control, Iterative control and
sequential control statements, Cursors, Views.
Learning Objective
Learning Outcome
• Type of control structure in Database Management
System.
• Discuss the concepts of cursor and its types.
• Discuss views in Database Management System.
What is PL/SQL
• Procedural Language – SQL
• An extension to SQL with design features of programming languages
(procedural and object oriented)
• PL/SQL and Java are both supported as internal host languages within
Oracle products.
Why PL/SQL
• Acts as host language for stored procedures and triggers.
• Provides the ability to add middle tier business logic to client/server
applications.
• Provides Portability of code from one environment to another
• Improves performance of multi-query transactions.
• Provides error handling
Structure of PL/SQL
• PL/SQL is Block Structured
A block is the basic unit from which all PL/SQL programs are built. A
block can be named (functions and procedures) or anonymous
• Sections of block
Declaration Section
Executable Section
Exception Section
Structure of PL/SQL
It is these controls, used singly or together, that allow the PL/SQL developer
to direct the flow of execution through the program.
LOOP
• Syntax • Example
WHILE
Syntax Example
• Executes a series of statements as declare
long as the given condition is true. i number(2) := 1;
begin
WHILE condition LOOP while i <= 10 loop
Statements;
END LOOP; dbms_output.put_line(i);
i := i + 1;
end loop;
end;
For
Syntax Example
This looping structure is best suited Declare
to cases where we have to repeatedly i int=1;
execute a set of statements by varying Begin
a variable from one value to another.
for i in 1..10 loop
FOR continued
If REVERSE option is used the following steps will take place:
GOTO Statement
Example
• DECLARE p VARCHAR2(30);
• n PLS_INTEGER := 37;
• BEGIN FOR j in 2..ROUND(SQRT(n)) LOOP IF n MOD j = 0
THEN p := ' is not a prime number';
• GOTO print_now; END IF; END LOOP;
• p := ' is a prime number'; <<print_now>>
DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || p);
• END; /
Output
37 is a prime number
NULL Statement
DBMS_OUTPUT.PUT_LINE
– An Oracle-supplied packaged procedure
– An alternative for displaying data from a PL/SQL block – Must be
enabled in SQL*Plus with SET SERVER OUTPUT ON
HOME WORK
1. In the PL/SQL block below, how many rows will be inserted in the messages table?
DECLARE
v_start_sales NUMBER := 2;
v_end_sales NUMBER := 100;
BEGIN
FOR i IN v_start_sales..v_end_sales LOOP
INSERT INTO messages(msgid)
VALUES v_start_sales;
END LOOP;
END;
a. 1
b. 0
c. 99
d. 100
2. Which statements execute a sequence of statements multiple times?
a. EXIT
b. LOOP
c. Both A & B
d. None of the above
Answer:1.C, 2.b
References
Other References
• Control Structures | DBMS | Tutorialink.com
• PL/SQL Control Structures - Oracle PL/SQL Tutorial | Intellipaat.com
• Writing PL/SQL Control Structures(Introduction) (relationaldbdesign.com)