Data Replication with SQL Remote
PART 1. Introduction to SQL Remote
CHAPTER 4. A Tutorial for Adaptive Server Anywhere Users
This tutorial describes how to set up a simple SQL Remote replication system using Adaptive Server Anywhere.
In the tutorial you act as the system administrator of a consolidated Adaptive Server Anywhere database, and set up a simple replication system. The replication system consists of a simple sales database, with two tables.
The consolidated database holds all of the database, while the remote database has all of one table, but only some of the rows in the other table.
The tutorial takes you through the following steps:
Creating a consolidated database on your Adaptive Server Anywhere server.
Creating a file-sharing replication system with a single Adaptive Server Anywhere remote database.
Replicating data between the two databases.
The tutorial uses a simple two-table database. One table holds information about sales representatives, and the other about customers. The tables are much simpler than you would use in a real database; this allows us to focus just on those issues important for replication.
The database schema for the tutorial is illustrated in the figure.
Features to note include the following:
Each sales representative is represented by one row in the SalesRep table.
Each customer is represented by one row in the Customer table.
Each customer is assigned to a single sales representative, and this assignment is built in to the database as a foreign key from the Customer table to the SalesRep table. The relationship between the Customer table and the SalesRep table is many-to-one.
The tables are described in more detail as follows:
Table |
Description |
---|---|
SalesRep |
One row for each sales representative that works for the company. The SalesRep table has the following columns:
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) ) |
Customer |
One row for each customer that does business with the company. The Customer table includes the following columns:
The SQL statement creating this table is as follows: CREATE TABLE Customer ( cust_key CHAR(12) NOT NULL, name CHAR(40) NOT NULL, rep_key CHAR(12) NOT NULL, FOREIGN KEY ( rep_key ) REFERENCES SalesRep (rep_key ), PRIMARY KEY (cust_key) ) |
The goals of the replication design are to provide each sales representative with the following information:
The complete SalesRep table.
Those customers assigned to them.
The tutorial describes how to meet this goal using SQL Remote.
The tutorial material is presented twice. One section describes how to set up the installation using the Sybase Central management utility. The second section describes how to set up the installation using command-line utilities: this requires typing commands individually.
To work through the tutorial using Sybase Central, go to A tutorial using Sybase Central, next.
To work through the tutorial entering commands explicitly, go to A tutorial using Interactive SQL and DBXTRACT.