Powered By Blogger

Sunday 26 February 2012

Index, Sequence, Synonym, DCL, TCL,Cluster Index,Pseduo Column,Constraints, Primary key, Unique Key


Data Control Language
These commands are used to grant the privileges or take back the granted privileges.
Grant Used to grant privileges.
Revoke Used to take back Privileges.
PRIVILEGES
1)   System level Privileges – they allow a user to perform certain actions within the DB.
·        DBA will grant these privileges to user.

Example – Create session, Create table, Create views, etc.

      2) Object level privilegesThey allow a user to perform certain action on DB objects.
* Granting a permission by one user of a DB to another user of a DB on a specify objects.
Select, update, delete, insert.

ROLE
A ROLE is a collection of Permissions (Privileges).
§      Oracle Default ROLES are DBA, CONNECT, RESOURCE.
§      Rather than assigning privileges one at a time directly to a USER, we can create a ROLE and assign privileges to that ROLE, then grant that ROLE to multiple user & ROLE.
§      When we add or delete privileges from all users and ROLE assign that ROLE Automatically RECEIVE or LOSE those Privileges.
§      We can assign multiple ROLES to a single user or one ROLE to another ROLE.





INDEX
Æ  Default index is B-Tree index.
Æ  Index is a db objects, provide a fast access path to column that are indexed.
Æ  It contains an entry for each value that appears in the Index columns.
Æ  Indexes are stored separately from actual data.
Æ  Index are independent of the table, it indexes both physically and logically.
Æ  Index do not have activated & deactivated.
Æ  We can use up to 16 COLUMNS as index.
Æ  Index are mostly useful on large tables and on column that are frequently appear in WHERE clause.
Æ  Index should not be done on a table with less than 100 rows.
Æ  It  will BETTER and FAST if data is loaded first and then index is created.
Æ  If the table is Index organized, then a secondary index can created.
Æ  If the Table is TEMPORARY table, then Index is also TEMPORARY.
Æ  We can create index on columns containing NULL or DUPLICATE if UNIQUE keyword is not used.
Æ  We can create index on column contains a large number of NULL.
Æ   We can’t specify both UNIQUE & BITMAP indexes on one table.
Æ  Index can be created or dropped at any time and have no effect on the base table or other index.
Æ  When table dropped, index will also drop.
Æ  More than one indexes are allow in one table.
Æ  Each DML operations that is committed on a  table with index, means that index must be updated.
Æ  PRIMARY KEY constraints create clustered indexes automatically if no clustered index already exists on the table and a non-clustered index is not specified when you create the PRIMARY KEY constraint.

Type of index
Simple index
 A simple index on column.
>create index sid on emp(empno);
Composite index
An index created on more than one  column of table.
>create index cid on emp(empno,ename);
Unique index
An index with unique constraint it will not allow duplicate values.
>create unique index uid on dept(dname)

Bit map index
Bitmap indexes are normally used to index low cardinality columns in a warehouse environment.(statics)
>create bit map index bmid on emp(deptno);

B-tree index
B tree index are normally used OLTP Environment.(Dynamic)

Function based index
             This function is created on the arithmetic expression on columns of table.
>Create index fid on emp(sal+comm.);

Reverse index
                     This is created on columns containing data in sequential order.
       >create index rid on emp(empno) reverse;
  Descending index
                      This is created on columns which are displayed in sorted order.
              >create index dixd on emp(ename asc, sal desc);




CLUSTER INDEX
Clustered index physically rearrange the data that users inserts in your tables.
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index.

NON-CLUSTER INDEX
The data is present in arbitrary order, but the logical ordering is specified by the index.
Non cluster index is a special type of index in which the logical order of the index does not match the physical sorted order of the row on the disk
If primary key is a cluster index it must be foreign key is non cluster index.

CLUSTER
¯  Cluster is a method of storing tables that are related and often access together.
¯  A cluster is a group of rows from separate table stored in a small disk block

Transaction control language (TCL)
Transaction
v  A transaction is a logical unit of work that contains one or more SQL statements.
v  A transaction begins with the first executable SQL statement. A transaction ends when it is committed or rolled back, either explicitly with a COMMIT or ROLLBACK statement or implicitly when a DDL statement is issued
v  DDL and DCL command is auto commit.
v  The current user can review the result of the data manipulation operation by querying the table.
v  Other user can’t view the result of the DML operations made by the current user
v  When the environment setting auto commit is ON,
v  >set  autocommit ON;
Commit is used to save the transaction to disc. i.e. to make change permanent to DB.
Roll back is used to undo the transactions.
Save point is used to identify a portion of the transaction, for rollback purpose.
A SAVEPOINT is a marker within a transaction that allows for a partial rollback.

SEQUENCE
o   Sequence is a DB object that can generate unique sequential value (serial Number).
o   Its automatic creates sequence.
o   Sequence value is often used for PRIMARY KEY’s & UNIQUE KEY’s.
o   When sequence is created, we can define its initial value and the increment between its value..
o   The maximum value generated by the sequence is 38 digits.
o   To generate starting value sequence NEXTVAL should be used.
·        >create sequence (seq_name)
·        [Increment by n
·        Start with n
·        Max value n/NOMAXVALUE
·        Min value n/NOMINVALUE
·        Cycle/Nocycle
·        Cache/Nocache
·        Order/No order];

Increment by
·         Specify the interval between the sequence numbers.
·         Value can be positive or negative but can’t be zero.
·         If the value is POSITIVE it is INCREMENT SEQUENCE.
·         If the value is NEGATIVE it is DECREMENT SEQUENCE.
·         Default increment is 1.
Start with n
·         Specify the starting value of sequence.
·         Default value is 1.
Min value
·        Specify the min value of sequence.
No min value
·         Specify a minimum value of 1 for ascending sequence.
·         -1026 for descending sequence.

Max value
·         Specify the max value of sequence.
No max value
·         Specify the maximum value of 1027 for ascending sequence.
·         -1 for descending sequence.
Cycle
·         Specify the sequence will continue to generate value after reaching either maximum or minimum value.
No cycle
·         Specify sequence can’t generate value after reaching max or min value.
·         Default is NO CYCLE.
Cache
·         Cache is a buffer.
·         It specifies the No. of integer to keep in memory.
·         Default cache is 20.
·         Minimum cache is 2.
Order
·        This guarantees that sequence Numbers are generated in the order of request.
No order
£  This does not guarantee that sequence Numbers are generated in the order of request.

©       Alter is available in sequence.
©       The START WITH OPTION can’t be changed using ALTER SEQUENCE.
©       To change START WITH OPTION, drop the SEQUENCE and then recreate the sequence.


ž  >ALTER sequence (seq_name)
ž  [Increment by n
ž  Max value n
ž  Min value n
ž  Cycle
ž  Cache];
PSEDUO COLUMN
Ø  Pseudo column behave like a table’s columns, but it is not stored in a table.
Ø  Upon pseudo column only SELECT statements can be implemented.
Ø  DML can’t be implemented.
Ø  The available Pseudo columns are..
A.    Currval
B.    Nextval
C.     Level
D.    Rowid
E.     Rownum
F.     Sysdate
CURRVAL- Return the current value of sequence.
NEXTVAL- Increment the sequence value by declared.

VIEW
¯  View is a logical table, based on one or more table or views.
¯  View contains NO data by itself.
¯   The table on which a view is based are called as BASE TABLE.
¯  View require no memory to store data but some  memory required for storing definition of view.
¯  View can replaced if already exit.
¯  We can create view without existing the table forcibly.
¯  Complex select statement can be stored in DB and retrieve the data writing simple select statements using view.
VIEW’S TYPE
n  Simple view
n  Complex view
n  Materialized view
SIMPLE VIEW
¯  A view based on single table.
¯  Simple view will not have any expression or group function.
¯  All DML allow in simple views.
¯  If table drop then view will not drop but view become invalid. View become valid when table again created with same as dropped table column name.
COMPLEX VIEW
®  Complex view is created on multiple table and group function.
®  Complex view is created only with READ ONLY OPTIONS.
®  DML are not allowed.
®  Through view we can insert data into child table not in parent table.
®  Select is allow.
MATERIALIZED VIEW
§  Simple and complex view will not have any data so they will not demand any space.
§  Materialized view contains both definition and data, it demand space.
§  DML not allowed.
§  Select is allowed.
§  Materialized view refreshed based on data in table.
§  To create materialized view with refreshment option, table should have atleast one primary key constraint column.
§  Order by clause is allowed in view onwards oracle 8i.
§  Alias must be defined for all columns of the view those are derived from arithmetic expression, function or pseudo column.
§  >create materialized view dept_mv
§  Refresh complete with rowid
§  Start with sysdate
§  Next sysdate+1/(24*60*60)
§  As
§  Select * from dept;

§  > create materialized view dept_mv
§  Refresh fast
§  Start with sysdate
§  Next sysdate+1/(24*60*60)
§  As
§  Select * from dept;
Difference between ROWID and ROWNUM.
                       Row id
                           RowNum
1.Physical address of the rows.

2.Rowid is permanent
3.Rowid is 16-bit hexadecimal
4.Rowid gives address of rows or records
5. Rowid is automatically generated unique id of a row and it is generated at the time of insertion of row.
6. ROWID is the fastest means of accessing data.
7. They are unique identifiers for the any row in a table.

1. Rownum is the sequential number, allocated to each returned row during query execution.
2. Rownum is temporary.
3.Rownum is numeric
4.Rownum gives count of records
5. Rownum is an dynamic value automatically
retrieved along with select statement output.
6. It represents the sequential order in which Oracle has retrieved the row.


Note::
v  We can’t use rowid as a PK.
v  We can change the rowid.
v  ROWID will change every time the record is physically moved.
v  Rownum indicates the order in which oracle engine selects the row from a table .
v  Rowid can’t change manually through DML operation.
SYNONYM
¯  A synonym is an alternative name for objects such as tables, views, sequences, stored procedures, and other database objects.
¯  We can avoid the entry of SCHEMA.
¯  DML operation performed on synonym will affect the table.
¯  The main functionality of synonym is to access the database objects between different schemas without using the schema names.

Types of Synonyms
§     Private synonyms- it is created by user.
¯  Public  synonyms-
F  Which can be accessed by all USERS in the DB?
F  Synonym created by user with CREATE PUBLIC SYNONYM privileges.     
>create synonym (syn_name) for scott.

Difference between VIEW and SYNONYM.
                          view
                        synonym
1.   It doesn’t contain data itself.

     2.view occupies no space for data

     3.view has only query


1. It contain data itself.

2.synonym occupy space for data

3.synonym can be used as an alias name for the table name


Constraint
Constraint is a rule or restriction.
Data integrity constraint
It is a constraint  which is enforce by oracle on columns of a table to maintain the accuracy & integrity of a data.
Unique
£  It will not allow duplicate values but allow null values.
£  Maximum of 32 columns are allow under one unique key, called composite or concatinate key.
£  Oracle create an index implicitly on unique key column.           
Not Null
¢  It will not allow null but allow the duplicate values.
¢  It is independent of data type.
¢  Not null constraint should be defined at column level.
¢  The default constraint is NULL
Primary key
¤  It is a combination of unique and not null constraint.
¤  It will not allow null and duplicates.
¤  Only one primary key allow per table.
¤  Maximum 32 columns allow for one primary key or composite key.
¤  We can’t create unique key and PK on same column.
¤  A master table can have any number of child tables.
¤  One PK has any number of foreign key.
¤  It is not possible to disable PK when it has FK referring it.
¤  It is also not possible to disable FK first and then PK.
Check
n  Used to enforce the condition rule.
n  Check, the values in specified list or not.
n  Check, the value in specify range or not.
n  Multiple Check allow in one table.



Foreign key
®  It is used for establish the parent-child or master-detailed relationship between tables.
®  We can define same column as foreign key & Primary/Unique key.
®  Foreign key allows duplicate and Null.
References
  It is establish relation between the columns of different table.
  Foreign key and ON DELETE CASCADE.
Self referenced key
F A Foreign key which is referring the Primary key of the same table is called SELF REFRENCED KEY.

Data, Attribute,dataType,functions


Data
F  Data is a raw fact which has have meaning and  no meaning.
F  Objects & event that have meaning and importance in the user’s environment.
Structured data    stud name, address, age… etc.    
Unstructured data    stud photo, address_ map… etc.

Meta data
It is the data which describe the properties or characteristics of end user data.
1.   Data name    2. Definition   3. Size   4. Source of data   5. Ownership

Entity
Entity can be anything in Real world, which has some properties, on the basis of those properties, it can be uniquely identify. Ex.. Student, Employee, etc..
Attributes
Properties of entity called “ATTRIBUTES”.
Ex..  std_name, std_contact, std_add, etc.
Data base
DB is organized collection of data as well as information.
DBMS
  DBMS is a S/W used to manage DB.
  Collection of integrated inter-related data.
  DBMS should provide systematic method of creating DB, updating DB, storing DB, etc..
Objective of DBMS
¤  Provide greater independence between Program & data.
¤  Reduce the maintenance cost of S/W.
¤  Manage complex data type & structure.
¤  Easier & fast access of data.
RDBMS-
     i.        RDBMS is a DBMS based on the relation model. 
    ii.        RDBMS stored the data in the form of related tables.
   iii.        RDBMS are powerful because they required few assumptions about how data is related or how it will extracted from the DB.
Data definition language (DDL)
a)   Create     b) Alter    c) Rename   d) Drop   e) Truncate
Data manipulation language (DML)
A.   Insert           B. Update            C. Delete         D. Merge
Data Retrieval/Query language (DRL)
1.   Selection            2. Projection            3.  Join
Data control language (DCL)
     I.        Grant            II.  Revoke
Transaction control language (TCL)
a.    Commit         b. Rollback        c. Save point
Database Object
a.    Table      b. View      c. Synonyms      d. Column      e. Sequence
Data type
1.   Character   2.  Numeric   3.  Date time   4.  Long raw   5.  Large object        6.  Rowid
Char ()
  To store fixed length character strings.
  Maximum size== 2000 byte
   Default size == 1byte
Varchar ()
  To store variable length.
  Maximum size== 4000 byte
  Default size==no

Long ()
¯  To store very lengthy text string
¯  Long is a variable length.
¯  Max size==2 GB
¯  A single table can contain only one LONG column.
¯  “LONG “column can’t appear in WHERE clause or integrity constraint.
¯  Index can’t create on LONG column.
¯  LONG column can appear in SELECT, INSERT and UPDATE.
Raw ()
¤  To store binary data like Images, signature, thumb impression etc.
¤  Max sizes== 2000 byte.
Long Raw ()
T  To store variable length binary data type.
T  Max sizes== 2 GB.
Large objects (LOB)
Q  Lobs can store upto 4GB.
Types of LOBs
¤  CLOB (character large object)
F  CLOB uses default character set.
F  CLOB could be some large text file (txt, csv, xml).
¤  BLOB (Binary large object)
F  We can specify the character set.
F  BLOB could be an image (jpeg, gif).

INSERT    Two way of insertion.
1} Conventional method-
Oracle reuse free space in the table into which the data in being inserted & maintain referential integrity.
2} Direct path method
Oracle append the inserted data after existing data in the table, the free space is not reuse.
INSERTING NULL VALUE
1] Implicit method- Omit the column from list.
2] Explicit method- Specify the null keywords.
n  Insert, update, and delete works on table at a time.
n  Sysdate is a function.
Coping table with values
>insert into emp1 select * from emp;
>create table emp_dup
As
Select * from emp;
NOTE= in this copy, constraint will not copied to another duplicate table.
Projection
Retrieving the data from the specify columns of table is projection.
Data dictionary
Data dictionary is the main source of information for every RDBMS
>select * from dict;
>select * from user_tables where table_name=’EMP’;
>select user from all_users; ( to view all user)
ALTER (Modify, Add, Rename, Drop/Disable/Enable)
1.   To change the size of column & data size.
2.   To make NULL to NOT NULL and NOT NULL to NULL.
3.   To change data type column must be empty.
4.   Before changing Null to Not Null of a column remove Null Values.
Operator precedence
*, /, +, -
Operators of the same priority are evaluated from left to right.
NOTE
Q  If any column value in an Arithmetic expression is NULL, the overall result is also NULL.
Q  If any row has same deptno then it will sort accordingly the record had entered.
Q  During sorting process oracle will consider NULL value as biggest value.
Null will place
&  NULL first in descending order.
& NULL last in ascending order.
Operators
     I.        Arithmetic Operator (+, -, *, /).
   II.        Relational Operator (>, =, <, >=, <=, IN, BETWEEN, LIKE, IS NULL).
 III.        Logical Operator (AND, OR, NOT).
 IV.        Set Operator (UNION, UNION ALL, INSERSECT, MINUS).
   V.        Boolean Operator (EXIST, NOT EXIST).
Difference between CHECK & WHERE
Þ   Check is used to check the range during insertion where clause is used to check the range while referring the data.
Function
  Function is used for calculate the calculation of data
  Modify the individual data.
  Format dates & number for display.
NOTE
ì  If a SQL function is called with a NULL argument, then a NULL is returned.
                                                    Type of function




 Single Row function                                                                 multiple row function
(This function return single result                          (this function manipulate group for every row of a table)                                                             of row and return one result per group of row

Ø  Numeric function=       (Accept numeric input return numeric value)
Ø  Character function=     (Accept character input return number & char both)
Ø  Date function=              (Accept date input return date & number)
Ø  Conversion function=   (convert a value one data type to another data type)
CEIL (n)-  It returns the smallest integer greater than given number.
>select  CEIL(5.5)  from dual; [6]
>select  CEIL(-5.5)   from dual; [-5]
>select  CEIL(5)  from dual; [5]
FLOOR (n)-  It return the greatest integer smaller than given number.
>select  FLOOR(5.5)  from  dual; [5]
>select  FLOOR(-5.5)  from  dual; [-6]
>select  FLOOR(5)  from dual; [5]
ROUND (m,n)-  It will round the given value for specify places.
>select round (2.315) from dual; [2]
>select round (2.767) from dual; [3]
> Select round (5678.12356, 3) from dual; [5678.124]
>select round (5678.1235, -1) from dual; [5680]
>select round (5678.1235, -2) from dual; [5700]
>select round (5678.1235, -3) from dual; [6000]
>select round(5678.1235, -4) from dual; [0000]
TRUNC (m, n)- It will truncate the given number upto specify precision.
>select trunc (2.315) from dual; [2]
>select trunc (2.767) from dual; [2]
> Select trunc (5678.12356, 3) from dual; [5678.123]
>select trunc (5678.1235, -1) from dual; [5670]
>select trunc (5678.1235, -2) from dual; [5600]
>select trunc (5678.1235, -3) from dual; [5000]
>select trunc (5678.1235, -4) from dual; [0000]
LTRIM (String, set) & RTRIM (String, set)
>select LTRIM (‘abcxyz’,  ‘abc’) from dual; [xyz]
>select RTRIM(‘abcxyz’,  ‘xyz’) from dual;  [abc]
LPAD & RPAD (String, number, Padding character)
>select LPAD(‘oracle’ ,8, ‘#’) from dual; [##oracle]
>select RPAD(‘oracle’ ,8, ‘#’) from dual; [ oracle##]
TRANSLATE (string, from char, to char)
>select TRANSLATE (‘ALLEN’, ‘AEI’, ‘#@$’) from dual; [#LL@N]
REPLACE (string, searching substring, replacing string)
>select REPLACE (‘light’ , ‘l’, ‘r’) from dual; [right]
SUBSTR (string, starting position, number of char)
Used to extract a substring from main string
>select SUBSTR (‘oracle’, 2) from dual; [racle]
>select SUBSTR (‘oracle’, 1, 3) from dual; [ora]
>select SUBSTR (‘oracle’, -1, 1) from dual; [e]
>select SUBSTR (‘oracle’, -2, 2) from dual; [le]
INSTR (string, char, starting position, occurrence)
It returns the numeric position of character in the given string.
>select INSTR(‘ADAMS’, ‘A’,1, 1) first from dual; [1]
>select INSTR(‘ADAMS’, ‘A’,1, 2) second  from dual; [3]
>select INSTR(‘ADAMS’, ‘A’,1, 3) third  from dual; [0]


RENAME
n  We can’t rename two tables or two columns simultaneously.
n  We can’t drop two tables simultaneously.
n  We can update more than one column at a time.

Difference between DROP, DELETE and TRUNCATE
          Drop
            Delete
           Truncate
1. Whole structure and data will drop.

2.can’t  Rollback

3.can’t use where clause

4.All data and structure
drop simultaneously
1. Structure will not drop, data will drop.

2.can Rollback

3.can use WHERE clause

4. Row by Row data Delete
1. Structure will not drop data will drop.

2.can’t Rollback

3.can’t use WHERE clause

4. Only all data will drop, truncate operation drop and recreate the table.

Difference between JOIN and UNION
                      Join
                    Union
1.   Join the columns.

2.   Duplicate are allowed

3.   Combine the column based on condition.
1.Merge the row

2.Duplicates are not allowed

3. Combine the result of two select statements.


WHERE Vs HAVING
                     Where
                    Having
1.Without group by clause

2. Where clause select Row before grouping.

3. Where clause can’t contain aggregate function.
1.With group by clause

2.Having clause select after grouping


3.Having clause contain aggregate
Function.

CURSOR

ü  Cursor is handle or pointer to the context area.
ü  The oracle engine used a work area for its internal processing and execute to an SQL statement.
ü  To execute SQL statements oracle needs to create an area of memory known as context area.
ü  Context area contains the information needed to process the statements. It includes also the number of row Processed by the statements.

Use of cursor
                     I.        Using the cursor, the PL/SQL program can control the context area.
                   II.        Cursor allow to FETCH  and  PROCESS  rows return by a select statement.

Cursor Type
Implicit Cursor- This is automatically declare by oracle every time an SQL statements is executed. The programmer can’t control or Process the information in an implicit cursor.
a)   This is automatically associated with every DML operation.
b)   All updates and delete statements have cursor that identifies the set of rows that will be affected by the operation.
c)   An insert statement needs a place to insert data in DB, which is also handle by implicit cursor.
d)   Implicit cursor automatically performs OPEN, FETCH and CLOSE the context area.

Explicit Cursor-It is  cursor that is define by the programmer within the program for query that returns more than one Row of Data.
a)   Explicit cursor area more efficient in implementation, hence easy to trap error.
b)   It is designed to work with SELECT statements that return more than one record at a time.

4 Steps for explicit cursor
1)   Cursor declaring
2)   Cursor opening
3)   Cursor fetching
4)   Cursor closing
Cursor Attributes
A) Cursor % ISOPEN
B) Cursor % FOUND
C) Cursor % NOTFOUND
D) Cursor % ROWCOUNT

Procedure/Function
®  Procedures are a named PL/SQL block, take parameters and perform an action.
®  Procedure or function is logically grouped set of PL/SQL and statements that perform a specify task.

Procedure Vs Function
                    Procedure
                   Function
1. Procedure doesn’t contain return clause in header & executable part.

2. Procedure may be return or may not be return a value.

3. Procedure can’t be called into select statements.

4. Procedure are used to implement business logic.
1. Function contain return clause in header & executable part.

2. Function always returns a value.


3. Function can be called into select statement.

4. Function are used for numeric calculation.




Package-
£  Package is PL/SQL construct that allow to store related objects together.
£  Package is a method is to handle all required function and procedure together.
£  Package contains variable, function, procedure, cursor & exception.
Package has two part
Package specification- contain
1)   Name of package
2)   Name of data type of any arguments.
3)   This declare is local to DB but global to package.
Package Body-
1)   It contain code of program that specified in package specification.
2)   Package body successfully compiled after the successfully compilation of package header.
Types of package.

Package “private” for object that are declare in side the package body.

Package “Public” for object that are declare within the package specification.

Subprogram Overloading
More than one procedure or function can be created with same name  & different parameters within the package.
Trigger
¯  Oracle define trigger as “procedure that are store in the DB and implicitly run or fired, when something happens.
¯  Procedure are implicitly executed when an INSERT, UPDATE or DELETE against the table, these procedure are called DB trigger.





¯  Trigger Vs Procedure
                  Trigger
                   Procedure
1.   Trigger does not accept parameters.

2.   A trigger is executed implicitly by the oracle engine.
1. Procedure accepts the parameters.


2.Procedure is execute explicitly, called by a user

On one particular table any number of triggers can be defined, but all these must belongs to 12 types of triggers.
Types of trigger-
Row trigger-
A Row trigger is fired each time, a Row is affected by the triggering statements (or trigger event).
Statement Trigger-
A statement trigger is fired once for the entire triggering statement. Number of row is affected or not affected but statement trigger fires at least once.
Before trigger
These trigger fires BEFORE any transaction is implemented.
After trigger
These trigger fires AFTER any transaction is implemented.
Use of Trigger
1)   Statistical information on table access.
2)   Preventing invalid transaction.
3)   Enforce complex business rule that can’t be define by in integrity constraint.