Database Reference
In-Depth Information
Further suppose that a user accesses the database via the following view, which is named RepCust:
CREATE VIEW RepCust (RNum, RLast, RFirst, CNum, CName) AS
SELECT Rep.RepNum, LastName, FirstName, Customer.CustomerNum, CustomerName
FROM Rep, Customer
WHERE Rep.RepNum=Customer.RepNum
;
The defining query is now invalid because there is no RepNum field in the Customer table. A relationship still
exists between reps and customers, however. The difference is that you now must go through the Territory table
to relate the two tables. If users have been accessing the tables directly to form the relationship, their programs
will have to change. If they are using the RepCust view, you will need to change only the definition of the view.
The new definition is as follows:
251
CREATE VIEW RepCust (RNum, RLast, RFirst, CNum, CName) AS
SELECT Rep.RepNum, LastName, FirstName, Customer.CustomerNum, CustomerName
FROM Rep, Territory, Customer
WHERE Rep.RepNum=Territory.RepNum
AND Territory.TerritoryNum=Customer.TerritoryNum
;
The defining query is now more complicated than it was before, but this does not affect users of the view.
The users continue to access the database in exactly the same way they did before, and the DBA won
'
t need
to change their programs.
SUPPORT DATA REPLICATION
A DBMS must manage multiple copies of the same data at multiple locations. For performance or other rea-
sons, sometimes data should be duplicated
at more than one physical loca-
tion. For example, accessing data at a local site is much more efficient than accessing data remotely. It
technically called replicated
s
more efficient because using replicated data does not involve data communication and network time delays,
users compete for data with fewer other users, and replicated data keeps data available to local users at times
when the data might not be available at other sites.
If certain information needs to be accessed frequently from all sites, a company might choose to store
the information at all its locations. At other times, users on the road
'
for example, reps meeting at their cus-
tomers
might need access to data but would not have this access unless the data was stored on their
portable computers.
Replication lets users at different sites use and modify copies of a database and then share their changes
with the other users. Replication is a two-step process. First, the DBMS creates copies, called replicas, of the
database at one or more sites. For example, you could create two replicas, as shown in Figure 7-17, and give
the
'
sites
Replica 1 database
to one user to access at a remote location and give the
Replica 2 database
to a
second user to use at a different remote location.
Master
database
Replica 2
database
DBMS
Replica 1
database
FIGURE 7-17
The DBMS creates replicas from the master database
The master database and all replicas form a replica set. Users then update their individual replicas, just
as if they were updating the master database. Periodically, the DBMS exchanges all updated data between the
Search WWH ::




Custom Search