Databases Reference
In-Depth Information
124
Data in view
FIGURE 4-9
Datasheet for the SalesCust view
The use of views provides several advantages:
Views provide data independence. If the database structure changes (by fields being added or rela-
tionships changing between tables, for example) in such a way that the view can still be derived
from existing data, the user can still access and use the same view. If adding extra fields to tables
in the database is the only change and these fields are not required by the view's user, the defin-
ing query may not even need to be changed for the user to continue using the view. If relation-
ships are changed, the defining query may be different; but because users need not be aware of the
defining query, this difference is unknown to them. They continue accessing the database
through the same view as though nothing has changed.
Because each user has his or her own view, different users can view the same data in different ways.
A view should contain only those fields required by a given user. This practice has two advantages.
First, because the view will, in all probability, contain fewer fields than the overall database and
the view is conceptually a single table, rather than a collection of tables, it greatly simplifies the
user's perception of the database. Second, views provide a measure of security. Fields that are not
included in the view are not accessible to the view's user. For example, omitting the Balance field
from a view will ensure that a user of the view cannot access any customer's balance. Like-
wise, rows that are not included in the view are not accessible. A user of the Housewares view,
for example, cannot obtain any information about parts in the AP or SG item classes.
INDEXES
If you want to find a discussion of a given topic in a book, you could scan the entire book from start to fin-
ish, looking for references to the topic you had in mind. More than likely, however, you wouldn't have to resort
to this technique. If the book had a good index, you could use it to quickly identify the pages on which your
topic is discussed.
Within relational model systems on both mainframes and personal computers, the main mechanism for
increasing the efficiency with which data is retrieved from the database is the index . Conceptually, these
indexes are very much like the index in a book. Consider Figure 4-10, for example, which shows the
Customer table for Premiere Products together with one extra field, RecordNum. This extra field gives the loca-
tion of the record in the file. (Customer 148 is the first record in the table and is on record 1, customer 282
is on record 2, and so on.) These record numbers are automatically assigned and used by the DBMS, not by
the users, which is why you do not normally see them. For illustrative purposes, Figure 4-10 includes a
RecordNum column to show how an index works.
 
Search WWH ::




Custom Search