User's Manual

Those rows from the Customer table listing customers that deal with the
sales rep subscribed to the data.
New problems The many-to-many relationship between customers and sales representatives
introduces new challenges in maintaining a proper sharing of information:
We have a table (in this case the Customer table) that has no reference to
the sales representative value that is used in the subscriptions to partition
the data.
Again, this problem is addressed by using a subquery in the publication.
Each row in the Customer table may be related to many rows in the
SalesRep table, and shared with many sales representatives databases.
Put another way, the rows of the Contact table in “Partitioning tables that
do not contain the subscription expression” on page 105 were partitioned
into disjoint sets by the publication. In the present example there are
overlapping subscriptions.
To meet the replication goals we again need one publication and a set of
subscriptions. In this case, we use two triggers to handle the transfer of
customers from one sales representative to another.
The publication
A single publication provides the basis for the data sharing:
CREATE PUBLICATION SalesRepData (
TABLE SalesRep,
TABLE Policy SUBSCRIBE BY rep_key,
TABLE Customer SUBSCRIBE BY (
SELECT rep_key FROM Policy
WHERE Policy.cust_key =
Customer.cust_key
),
);
The subscription statements are exactly as in the previous example.
How the publication
works
The publication includes part or all of each of the three tables. To understand
how the publication works, it helps to look at each article in turn:
SalesRep table There are no qualifiers to this article, so the entire
SalesRep table is included in the publication.
...
TABLE SalesRep,
...
Policy table This article uses a subscription expression to specify a
column used to partition the data among the sales reps:
114