Advantages of Views

Advantages
In the case of a DBMS running on a standalone PC, views are usually a convenience,
defined to simplify database requests. However, in a multi-user DBMS, views play a central
role in defining the structure of the database and enforcing security. The major advantages
of views are described below.
Data independence
A view can present a consistent, unchanging picture of the structure of the database, even
if the underlying source tables are changed (for example, columns added or removed, relationships
changed, tables split, restructured, or renamed). If columns are added or removed
from a table, and these columns are not required by the view, then the definition of the
view need not change. If an existing table is rearranged or split up, a view may be defined
so that users can continue to see the old table. In the case of splitting a table, the old table
can be recreated by defining a view from the join of the new tables, provided that the split
is done in such a way that the original table can be reconstructed. We can ensure that this
is possible by placing the primary key in both of the new tables. Thus, if we originally had
a Client table of the form:
Client (clientNo, fName, lName, telNo, prefType, maxRent)
we could reorganize it into two new tables:
ClientDetails (clientNo, fName, lName, telNo)
ClientReqts (clientNo, prefType, maxRent)
Users and applications could still access the data using the old table structure, which would
be recreated by defining a view called Client as the natural join of ClientDetails and ClientReqts,
with clientNo as the join column:
CREATE VIEW Client
AS SELECT cd.clientNo, fName, lName, telNo, prefType, maxRent
FROM ClientDetails cd, ClientReqts cr
WHERE cd.clientNo = cr.clientNo;
Currency
Changes to any of the base tables in the defining query are immediately reflected in the
view.
Improved security
Each user can be given the privilege to access the database only through a small set of
views that contain the data appropriate for that user, thus restricting and controlling each
user’s access to the database.
Reduced complexity
A view can simplify queries, by drawing data from several tables into a single table, thereby
transforming multi-table queries into single-table queries.
Convenience
Views can provide greater convenience to users as users are presented with only that part
of the database that they need to see. This also reduces the complexity from the user’s
point of view.
Customization
Views provide a method to customize the appearance of the database, so that the same
underlying base tables can be seen by different users in different ways.
Data integrity
If the WITH CHECK OPTION clause of the CREATE VIEW statement is used, then
SQL ensures that no row that fails to satisfy the WHERE clause of the defining query is
ever added to any of the underlying base table(s) through the view, thereby ensuring the
integrity of the view.
Advantages of Views Advantages of Views Reviewed by Muneeb Masood on 12:57 Rating: 5

No comments:

Powered by Blogger.