In this lesson, you create a synchronization model for your consolidated database.
Connect to the consolidated database by creating a new MobiLink project.
Choose Start » Programs » SQL Anywhere 12 » Administration Tools » Sybase Central.
From the Tools menu, choose MobiLink 12 » New Project.
In the Name field, type ase_project.
In the Location field, type C:\mlase, and then click Next.
Check the Add A Consolidated Database To The Project option.
In the Database Display Name field, type ase_cons.
Click Edit. The Connect To A Generic ODBC Database window appears.
In the User ID field, type sa.
In the Password field, type the password for the sa account.
In the ODBC Data Source name field, click Browse and select ase_cons.
Click OK, then click Save.
Check the Remember The Password option, and then click Next.
Choose the Create a new model option, and then click Next.
Check the Add a remote schema name to the project option.
Type ase_remote_schema for the remote schema name, and then click Finish.
The Create Synchronization Model Wizard provides step-by-step instructions for setting up synchronization between the consolidated database and remote database.
On the Welcome page, type sync_ase in the What Do You Want To Name The New Synchronization Model field, and then click Next.
On the Primary Key Requirements page, select all three check boxes (you guarantee unique primary keys in Lesson 2). Click Next.
Select the ase_cons consolidated database from the list, and then click Next.
Click No, Create A New Remote Database Schema, and then click Next.
On the New Remote Database Schema page, in the Which Consolidated Database Tables And Columns Do You Want To Have In Your Remote Database list, select the following tables:
Click Next.
Click Timestamp-based Download, and then click Next.
Timestamp-based downloads minimize the amount of data that is transferred because only data that has been updated since the last download is transmitted.
On the Timestamp Download Options page, click Use Shadow Tables To Hold Timestamp Columns, and then click Next.
Using shadow tables is often preferred because it does not require any changes to existing tables.
Perform the following tasks on the Download Deletes page:
Click Yes on the Do You Want Data Deleted On The Consolidated Database To Be Deleted On The Remote Databases option.
Click Use Shadow Tables To Record Deletions.
MobiLink creates shadow tables on the consolidated database to implement deletions.
Click Next.
Click Yes, Download the Same Data to Each Remote, and then click Next.
You specify how to download specific data to a remote database by using custom logic when editing the synchronization model.
Click No Conflict Detection, and then click Next.
Although this tutorial specifies no conflict detection, many applications require conflict detection.
Perform the following tasks on the Publication, Script Version and Description page:
In the What Do You want To Name The Publication field, type sync_ase_publication.
In the What Do You Want To Name The Script Version field, type sync_ase_scriptversion.
The publication is the object on the remote database that specifies what data is synchronized. MobiLink server scripts define how uploaded data from remotes should be applied to the consolidated database, and script versions group scripts. You can use different script versions for different applications, allowing you to maintain a single MobiLink server while synchronizing different applications.
Click Finish.
From the View menu, choose Folders.
In the left pane of Sybase Central under MobiLink 12, expand ase_project, Synchronization Models and then sync_ase.
Set the direction that data is synchronized for each table in the synchronization model.
Click the Mappings tab in the right pane, and then set the rows the Dir column as follows:
Filter the rows downloaded to the remote database by remote ID.
For the row containing the stores table, change the Download Subset to Custom.
Click the Download Subset tab at the bottom of the right pane.
Filter the rows by remote ID, which uniquely identifies the remote database, by adding a restriction to the WHERE clause of the download_cursor script.
Type a search condition in the SQL Expression To Use In The Download Cursor's WHERE Clause field. For example, the following SQL script can be used for the stores table:
"dbo"."stores"."stor_id" = {ml s.remote_id} |
The download cursor script specifies what columns and rows are downloaded from each table to the remote database. The search condition ensures that you only download information about one store, namely, the store that has an identifier that equals the remote ID for the database.
Repeat step 3 for the rows containing the sales, salesdetail, and discounts tables.
You must rename the table specified in the SQL script to the table name in the row that you are editing.
Use the following WHERE clause script for the salesdetail table:
"dbo"."salesdetail"."stor_id" = {ml s.remote_id} |
Use the following WHERE clause script for the discounts table:
"dbo"."discounts"."stor_id" = {ml s.remote_id} |
Save the synchronization model.
From the File menu, choose Save.
The synchronization model is complete and ready for deployment.
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |