You are on page 1of 14

ADVANCED DATABASE MANAGEMENT SYSTEM

DIPLOMA IN COMPUTER ENGINEERING (GTU)


SEMESTER: 4
SUBJECT CODE: 3340701

Unit 1: Lecture 7

EXPLAINATION & VOICE BY:


Mr. NIKUL JAYSWAL
Lecturer in Computer Engineering
Shri K. J. Polytechnic, Bharuch
RECAP
•Database Objects.
•Introduction to Views.
•Types of Views.
•Creating a View.
TODAY’S LECTURE OUTCOMES
•Restriction on View.
•Advantages of View.
•Destroying Views.
RESTRICTION ON VIEW
▪For a view to be updateable, there are some restrictions.
▪To be updateable, any view, created either using single base table or
multiple base tables, must not include:
- DISTINCT, GROUP BY and HAVING clause.
- Aggregate functions like MAX, MIN, SUM, AVG, COUNT.
- Set operations like UNION, UNION ALL, INTERSECT, and MINUS
-Sub-queries
RESTRICTION ON VIEW
▪Along with these, there are restrictions on INSERT, UPDATE and DELETE
operations based on how views are created:
▪A View defined using Single Base Tables:
OPERATION Allowed OR Not Allowed
SELECT Allowed
INSERT Allowed, only if PRIMARY KEY and NOT NULL columns
are included the view definition.
UPDATE Allowed
DELETE Allowed
RESTRICTION ON VIEW
▪A View defined using Multiple Base Tables (Having No Referencing Clause):
▪If a view is created from multiple base tables, and these tables are not
linked logically, i.e. there is no foreign key defined between them, then,
following restrictions are enforced on various operations.

OPERATION Allowed OR Not Allowed


SELECT Allowed
INSERT Not Allowed
UPDATE Not Allowed
DELETE Not Allowed
RESTRICTION ON VIEW
▪A View defined using Multiple Base Tables (Having Referencing Clause):
▪If a view is created from multiple base tables, and these tables are linked
logically, i.e. there is foreign key defined between them, then, following
restrictions are enforced on various operations.

OPERATION Allowed OR Not Allowed


SELECT Allowed
INSERT Not Allowed
UPDATE Allowed, but only on columns of the detail table included in view.
DELETE Allowed, but only records from the detail table will be deleted
ADVANTAGES OF VIEW
▪There are two major advantages of using views:
1. Flexible enforcement of Security.
2. Simplification of Complex Query.
FLEXIBLE ENFORCEMENT OF SECURITY
(ADVANTAGE OF VIEW)
▪Using views, only limited view of table data can be provided to
different users.
▪This is possible by limiting columns and rows in definition of view.
▪This helps in enforcing security in flexible way.
▪For example, to allow class teacher to access only their class
students, there must be separate tables for such.
▪But, this results in data redundancy and complex database design,
which is difficult to manage.
FLEXIBLE ENFORCEMENT OF SECURITY
(ADVANTAGE OF VIEW)
▪Instead of having separate tables for each class, separate views
can be created on the base table.
▪And, privileges can be given on these views rather than entire
base table.
▪Example:
CREATE VIEW classA AS SELECT * from student where eno
between 111 and 113;
GRANT ALL ON classA to teacher1;
SIMPLIFICATION OF COMPLEX QUERY
(ADVANTAGE OF VIEW)
▪Using views, complex queries can be simplified.
▪For example: Retrieve name of branch and city of branch of
account ‘101’.
▪Normal Way:
select actno, deposit.bname, city from deposit, branch where
deposit.bname=branch.bname and actno=101;
SIMPLIFICATION OF COMPLEX QUERY
(ADVANTAGE OF VIEW)
▪Create View:
create view deposit_branch as select ano, deposit.bname
branch_name ,city from deposit, branch where
deposit.bname=branch.bname;

select actno, branch_name, city from deposit_branch, where


actno=101;
DESTROYING A VIEW
▪Syntax:
DROP VIEW viewName;
▪The DROP VIEW command drops the specified view.
▪The base tables will not be affected if a view is destroyed.
▪If a base table is dropped or columns included in view are
altered, then view will not be valid further.
▪Oracle issues an error message while using such in-valid views
THANK YOU…..
Appear for Quiz Assignment in Microsoft Teams.
Note: It is mandatory for all students to appear for quiz assignment, it will be
considered as present in lecture and marks will be count as progressive
assessment.
If you do not appear than it will be considered as Absent in class and marks
will be 0 (zero).

You might also like