Sybase SQL Remote DC38133-01-0902-01 User Manual

Page of 485
Sharing rows among several subscriptions
There are cases where a row may need to be included in several
subscriptions. For example, we may have a many-to-many relationship. In
this section, we use a case study to illustrate how to handle this situation.
The Policy example
The Policy database illustrates why and how to partition tables when there is
a many-to-many relationship in the database.
Example database
Here is a simple database that illustrates the problem.
Policy
policy_key
cust_key
rep_key
SalesRep
rep_key
name
Customer
cust_key
name
Each sales representative sells to several customers, and some customers
deal with more than one sales representative. In this case, the relationship
between Customer and SalesRep is thus a many-to-many relationship.
The tables in the
database
The three tables are described in more detail as follows:
Table
Description
SalesRep
All sales representatives that work for the company. The
SalesRep table has the following columns:
rep_key
An identifier for each sales representative.
This is the primary key.
name
The name of each sales representative.
The SQL statement creating this table is as follows:
CREATE TABLE SalesRep (
Rep_key CHAR(12) NOT NULL,
Name CHAR(40) NOT NULL,
PRIMARY KEY (rep_key)
);
112