Database Reference
In-Depth Information
Views enable you to see the information in your database from many different aspects,
providing you with a great amount of flexibility when you work with your data. You can
create views in a variety of ways, and they are especially useful when you base them on
multiple related tables.
There are several reasons why you should define and use views in your database.
•
You can use them to work with data from multiple tables simultaneously.
During
the database design process, you established relationships between various pairs of
tables bearing one-to-many or many-to-many relationships to each other. (Recall
that you resolved the many-to-many relationships via linking tables.) A view
provides the mechanism that allows you to work with data from two or more re-
lated tables simultaneously.
•
They reflect the most current information.
Because the RDBMS rebuilds and re-
populates the view every time you access it, the information displayed by the view
exhibits the most recent changes to the data in its base tables.
•
You can customize them to the specific needs of an individual or group of individu-
als.
You can build a view to suit any set of requirements, such as providing the
data for a particular report or providing a means of examining specific information
that is common to several departments within an organization.
•
You can use them to help enforce data integrity.
You can define a
validation view
that works in the same manner as a validation table—its purpose is to provide a
valid range of values for a given field in the database.
•
You can use them for security or confidentiality purposes.
You can determine what
data is available to a particular user or group of users by defining a view on select
fields from the view's base tables.
Define your views carefully and skillfully, and they will become a valuable asset after
you've implemented the database within your RDBMS.
Anatomy of a View
There are three types of views (
data, aggregate,
and
validation
) that you can define as you
design the logical structure of the database and two types of views (
materialized
and
parti-
tioned
)thatyoucandefineasyouimplement yourdatabasewithinanRDBMS.Theability
to define the latter two types of views and the manner in which you do so are highly de-
pendent upon your RDBMS, so they are beyond the scope of this topic. We will, therefore,
focus our attention on the first three types of views.