Chapter 8. SQL Remote Design for Adaptive Server Enterprise

Table

Description

 

 

 

 

Contact

All individual contacts that do business with the company.

 

Each contact belongs to a single customer. The Contact

 

table includes the following columns:

 

contact_key

An identifier for each contact. This is

 

the primary key.

 

 

name

The name of each contact.

 

cust_key

An identifier for the customer to which the

 

contact belongs. This is a foreign key to the Customer

 

table.

 

 

 

 

The SQL statement creating this table is:

 

CREATE TABLE Contact (

 

contact_key

CHAR(12) NOT NULL,

 

name

CHAR(40) NOT NULL,

 

cust_key

CHAR(12) NOT NULL,

 

FOREIGN KEY (cust_key)

 

REFERENCES Customer,

 

PRIMARY KEY

(contact_key)

 

)

 

 

 

 

go

 

 

 

 

 

 

 

 

Replication goals

The goals of the design are to provide each sales representative with the

 

following information:

 

The complete SalesRep table.

 

Those customers assigned to them, from the Customer table.

 

Those contacts belonging to the relevant customers, from the Contact

 

table.

 

Maintenance of proper information when Sales Representative territories

 

are realigned.

Territory realignment in the Contact example

In territory realignment, rows are reassigned among subscribers. In the current example, territory realignment involves reassigning customers among the sales representatives. It is carried out by updating the rep_key column of the Customer table.

The UPDATE is replicated as an INSERT or a DELETE to the old and new sales representatives, respectively, so that the customer row is properly transferred to the new sales representative.

151

Page 169
Image 169
Sybase DC38133-01-0902-01 manual Following information, Are realigned