Database Reference
In-Depth Information
126
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 (because of fields being
added or relationships 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 defining query may not even need to be changed for the user to continue using
the view. If relationships 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 advan-
tages. First, because the view will, in all probability, contain fewer fields than the overall data-
base 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, omit-
ting the Balance field from a view will ensure that a user of the view cannot access any custo-
mer
'
s balance. Likewise, 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 finish,
looking for references to the topic you had in mind. More likely, however, you would not have to resort to
this technique. If the topic 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
location 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 its 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