Chapter 7. SQL Remote Design for AdaptiveSer verAnywhere
...TABLE Policy
SUBSCRIBE BY rep_key,
...
Thesubscription expression ensures that each sales rep receives only
thoserows of the table for which the value of the rep_key column
matchesthe value provided in the subscription.
ThePolicy table partitioning is disjoint: thereare no rows that are shared
withmore than one subscriber.
Customertable Asubscription expression with a subquery is used to
definethe partition. Thearticle is defined as follows:
...TABLE Customer SUBSCRIBE BY (
SELECT rep_key
FROM Policy
WHERE Policy.cust_key =
Customer.cust_key
),
...
TheCustomer partitioning is non-disjoint: somerows are shared with
morethan one subscriber.
Multiple-valued
subqueries in
publications
Thesubquery in the Customer article returns a single column (rep_key) in
itsresult set, but may return multiple rows, corresponding to all those sales
representativesthat deal with the particular customer. When a subscription
expressionhas multiple values, the row is replicated to all subscribers whose
subscriptionmatches any of the values. Itis this ability to have
multiple-valuedsubscription expressions that allows non-disjoint
partitioningsof a table.
Territory realignment with a many-to-manyrelationship
Theproblem of territory realignment (reassigning rows among subscribers)
requiresspecial attention, just as in the section “Territory realignment in the
Contactexample” on page 107.
Youneed to write triggers to maintain proper data throughout the installation
whenterritory realignment (reassignment of rows among subscribers) is
allowed.
Howcustomers are
transferred Inthis example, we require that a customer transfer be achieved by deleting
andinserting rows in the Policy table.
Tocancel a sales relationship between a customer and a sales representative,
arow in the Policy table is deleted. Inthis case, the Policy table change is
properlyreplicated to the sales representative, and the row no longer appears
115