The Policy database illustrates why and how to partition tables when there is a many-to-many relationship in the database.
Here is a simple database that illustrates the problem.
Each sales representative sells to several customers, and some customers deal with more than one sales representative. In this case, the relationship between Customers and SalesReps is thus a many-to-many relationship.
The three tables are described in more detail as follows:
Table | Description | ||
---|---|---|---|
SalesReps |
All sales representatives that work for the company. The SalesReps table has the following columns:
The SQL statement creating this table is as follows:
|
||
Customers |
All customers that do business with the company. The Customers table includes the following columns:
The SQL statement creating this table is as follows:
|
||
Policy |
A three-column table that maintains the many-to-many relationship between customers and sales representatives. The Policy table has the following columns:
The SQL statement creating this table is as follows.
|
The goals of the replication design are to provide each sales representative with the following information:
The many-to-many relationship between customers and sales representatives introduces new challenges in maintaining a proper sharing of information:
Again, this problem is addressed by using a subquery in the publication.
Put another way, the rows of the Contacts table in Partitioning tables that do not contain the subscription expression were partitioned into disjoint sets by the publication. In the present example there are overlapping subscriptions.
To meet the replication goals, you need one publication and a set of subscriptions. In this case, you can use two triggers to handle the transfer of customers from one sales representative to another.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |