Customer

cust_key

name

subscription_list

Policy

policy_key

cust_key

rep_key

SalesRep

rep_key

name

Table definitions

Notes:

The publication

Adaptive Server Enterprise VARCHAR columns are limited to 255 characters, and this limits the number of values that can be stored in the comma-delimited list.

The table definitions are as follows:

CREATE TABLE SalesRep ( rep_key CHAR( 12 ) NOT NULL, name CHAR( 40 ) NOT NULL, PRIMARY KEY ( rep_key )

)

go

CREATE TABLE Customer ( cust_key CHAR( 12 ) NOT NULL, name CHAR( 40 ) NOT NULL, subscription_list VARCHAR( 255 ) NULL, PRIMARY KEY ( cust_key )

)

go

CREATE TABLE Policy (

policy_key

INTEGER NOT NULL,

cust_key CHAR( 12 ) NOT NULL,

rep_key CHAR(

12 ) NOT NULL,

FOREIGN KEY

( cust_key )

REFERENCES Customer (cust_key ),

FOREIGN KEY (rep_key )

REFERENCES SalesRep ( rep_key ), PRIMARY KEY (policy_key)

)

The subscription_list column in the Customer table allows NULLs so that customers can be added who do not have any sales representatives in the subscription_list column.

The publication for this database can be created by the following set of statements:

//Mark the tables for replication exec sp_add_remote_table ’SalesRep’ exec sp_add_remote_table ’Policy’ exec sp_add_remote_table ’Customer’ go

158

Page 176
Image 176
Sybase DC38133-01-0902-01 manual 158, Foreign KEY