Вы находитесь на странице: 1из 2

TRIGGER: a trigger difference an action the data base should take when some database

related event occurs. Trigger may be use to supplement the declarative referential
entrgretty, twelve force complex business rules of two oddity changes to data. The code
with him integrate called the trigger body, is made up of PL/SQL block.
The execution of trigger is transparent to the user. Triggers are executed by the
database manipulation commands are perform of specific tables such commands may
include INSERT, UPDATE, DELETE.

TYPES OF TRIGGER A triggers types is defined by the type of triggering conduction and
by the label which the trigger is executed

1. Row-level trigger: - Row-level triggers execute once for each roles, affected by
a DML statement. Row-level trigger are the most command type of trigger.
They are often use in data auditing application. Row-level trigger are created by
using the FOR EACH ROW clause in the CREATE TRIGGE R command.
2. Statement-level trigger: - Statement-level trigger execute once for each DML
statement. For example, if a single INSERTS 500 rows into the book self table, a
statement-level trigger on that table would only be executed once. Statement level
trigger their fore are not often use for data related activities. They are normally used
to enforce additional security major on the types of action that may be performing
on a table. Statement-level trigger other default type of trigger, created via the
CREATE TRIGGER command.
3. Before and after trigger: - Because triggers are executed by events, they may
be set to occur immediately before or after those events. Sees the events that
executed trigger implicity, include data base DML statement, and the
statements are-INSERT, UPDATE, DELETE.
4. Instead of trigger: - We can use INSTEAD of trigger to oracle or to do
instead of performing the actions that invoke the trigger.
For example- A join of two tables has been occur
through a view. Our ability to use the UPDATE command on records
in the view is limited How ever if we use and INSTEAD OF trigger,
we can tell oracle how to update,delete,insert,records in the original
table when and user item to change values via the view.
5. Schema trigger: we can create triggers on it schema level operation such as
CREATE TABLE command, ALTER TABLE, DROPPED TABLE, AUDIT, RENAME,
TARNCATE, and REVOKE. Schema-level trigger provide two capabilities,
(a) Preventing DDL operation
(b) Providing additional security
(c) Monitoring when DDL operation occur
6. Database level trigger: we can create triggers to be fired on
database evens including errors, log in, log off, shut down and start
up. We can use this type of trigger to automate database
maintained or auditing actions.

Cursor: for every SQL Statement execution certain area in memory is allocated. PL/SQL
allows ask to name this area. This private SQL area is called context or cursor. A cursor acts
as a handle or pointer into the context area. APL/SQL program controls the context area
using the cursor. Cursor represents a stricture in memory and is different from cursor
variable. When we declare a cursor, we gate a pointer variable, which does not point
anything. When the cursor is open, memory is allocated and the cursor structure is
created. Now the cursor variable points the cursor. When the cursor is closed the memory
allocated for the cursor is released.
Cursor allow the
programmer to retrieve data for a table and perform action on that data one row at a time
.there are two types of cursor---

1. Implicit cursor: for SQL quarries returning single row PL/SQL declares implicit
cursor. Implicit cursors are simple SELECT, statement and are written in the
BEGIN block (executable section) of the PL/SQL. Implicit cursor are easy to
code, and a retrieve exactly on row. PL/SQL IMPLISITLY declares cursor for all
DML statement. The most commonly raised exceptions here are NO_DATA
_FOUND or TOO_MANY_ROWS.

2. EXPLICIT CURSOR ATTRIBUTE: Every cursor define by the user has four
attribute. When appended two the cursor name these attributes let the user
access useful information about the execution of a multidrug quarry.
The
attributes are –
1. %NOTFOUND: It is bullion attributes. Which evaluates to true if the last
failed that means when there are no rows left in the cursor to fetch.
2. %FUOND: it is bullion attributes. Which evaluates to true if the last fetch
succeeded
3. %ROWCOUNT: it is a numeric attributes which returns numbers of rows
fetch by the cursor so far.
4. %ISOPEN: it is bullion attributes which evaluates to true if the cursor is
open otherwise to false.

REDUNDANCY: Redundancy means repetition of data. Redundancy increases the time


involved in update in, adding and deleting data. It also increases the
initialization of this space.

Normalization: Normalization is scientific method of breaking down a complex table


structure into simple table structure by using certain rules. Using this method
we can reduce redundancy in a table and eliminate the problem of
inconsistency and this space uses. We can also ensure that there is no loss of
information.

Rules to achieve a good data base design: 1.Each table should have and unique identifier.

2. Each table should store data for a single type of entity.

3. Columns that accept NULLS should be avoided.

4. The repetition of values all columns should be avoided.

Benefit of normalization: Normalization has several benefits. It enables faster sorting and
index pleasant, more clustered indexes, view indexes per table, few NULLS and next the
data base more compact. Normalization has to simplify the structure of a table.

Forms of normalization: Normalization results in the formation of tables that satisfy.


Certain specified rules and represent certain normal forms. A table’s structure always
romance in a certain normal form. Several normal forms are there. The most information
and widely use normal forms are-

(i)First normal form (1mf)

(ii)Second normal form (2nf)

(iii)Third normal form (3nf)

(iv)Boyce-code normal form (BCNF)

The first,second,third normal forms were originally defined by dr. E.F. codd. Later boyce
and codd introduced another normal form cold the boyce-codd normal form (BCNF)

First normal forms (1NF): A table is set to be first normal form when each cell of the table
contain preciously one value.

Super key: The key or column on which other column of the same table are functionally
depended, is called super key.

Second normal forms (2NF): A table is set to be in second normal form when it is in fast
normal form and every attribute in the table is functionally depended upon the whole
key,and not on the part of the key.

Third normal form (3NF): A table is set to be in third normal form and when it is in second
normal form and every non key attribute is functionally depended only on the primary key.