Data Views Lecture Note PDF
Data Views Lecture Note PDF
Systems
Views
Conceptual Layer
Base Tables
Physical Layer
View Tables
Department Employee
Dept_Code Dep_Name Manager Emp_No Emp_Name Designation DOB Dept
179 Silva Manager 12-05-74 SAL
SAL Sales 179
857 Perera Accountant 01-04-67 FIN
FIN Finance 857
342 Dias Programmer 25-09-74 SAL
Base Tables
2010, University of Colombo School
of Computing
What Are User views?
A view is a Virtual Table. In SQL terminology,
view is a single table that is derived from other
tables.
User views
Derived or virtual tables that are visible to
users
Do not occupy any storage space
Base Tables
Store actual rows of data
Occupy a particular amount of storage space
2010, University of Colombo School
of Computing
Characteristics of User views
Behave as if it contains actual rows of data,
but in fact contains none.
Rows are derived from base table or tables
from which the view is defined.
Being virtual tables the possible update
operations that can be applied to views are
limited. However, it does not provide any
limitations on querying a view.
Works_On1
Fname Lname Pname Hours
Natural Interface
Personalized view of database structure, that
make sense for the user. Restructure or tailor
the way in which tables are seen, so that
different users see it from different
perspectives, thus allowing more natural
views of the same enterprise (e.g. item names)
Drop a View
DROP VIEW view-name
E.g.
DROP VIEW Emp_Payroll
UPDATE Works_On1
SET Pname = ProductY
WHERE Lname = Perera AND Fname = Sunil
AND Pname = ProductX;
31
Eg:
CREATE VIEW Emp_View AS
SELECT *
FROM Employee
WHERE Dept = SAL
WITH CHECK OPTION
This would cause the row to migrate from this view. But WITH
CHECK OPTION clause in the definition of the view prevents
this from happening
32
Limitations of User views
33
Limitations
Performance
DBMS must translate queries against the
view to queries against the source tables.
These disadvantages means that we
cannot indiscriminately define and use
views instead of source tables.
34