Lesson 4: Create a synchronization model

The Create Synchronization Model Wizard provides step-by-step instructions for setting up synchronization between the consolidated database and remote database.

To create a synchronization model
  1. Start Sybase Central.

  2. Choose Tools » MobiLink 11 » Set Up MobiLink Synchronization.

  3. On the Welcome page, in the What Do You Want To Name The New Synchronization Model field, type sync_ase and specify a location for your new model. Click Next.

  4. On the Primary Key Requirements page, select all three checkboxes (you guarantee unique primary keys in Lesson 2). Click Next.

  5. On the Consolidated Database Schema page do the following:

    1. Click Choose The Consolidated Database.

    2. Click ODBC Data Source Name and choose ase_cons.

    3. In the User ID field, type sa.

    4. In the Password field, type sa.

    5. Click OK.

      If this is the first time the consolidated database has been used by MobiLink, a message appears asking if you want to install the MobiLink system setup. Click Yes.

    6. Click Next.

  6. On the Remote Database Schema page, click No, Create A New Remote Database Schema. Click Next.

  7. On the New Remote Database Schema page, in the Which Consolidated Database Tables Do You Want To Have In Your Remote Database list, select the following tables:

    • au_pix
    • authors
    • discounts
    • sales
    • salesdetail
    • stores
    • titleauthor
    • titles
  8. Click Next.

  9. On the Download Type page, click Timestamp-based Download. Click Next.

    Choosing timestamp-based downloads minimizes the amount of data that is transferred because only data that has been updated since the last download is transmitted.

  10. On the Timestamp Download Options page, click Use Shadow Tables To Hold Timestamp Columns. Click Next.

    Using shadow tables is often preferred because it does not require any changes to existing tables.

  11. On the Download Deletes page, do the following:

    1. In the Do You Want Data Deleted On The Consolidated Database To Be Deleted On The Remote Databases field, click Yes.

    2. Click Use Shadow Tables To Record Deletions.

      MobiLink creates shadow tables on the consolidated database to implement deletions.

    3. Click Next.

  12. On the Download Subset page, click Yes, Download the Same Data to Each Remote. Click Next.

    In Step 2 of the Model mode lesson, you specify how to download specific data to a remote database by using custom logic.

  13. On the Upload Conflict Detection page, click No Conflict Detection. Click Next.

    Although this tutorial specifies no conflict detection, many applications require conflict detection.

  14. On the Publication, Script Version and Description page, do the following:

    1. In the What Do You want To Name The Publication field, type sync_ase_publication.

    2. 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.

    3. Click Finish.

      Your model appears in Model mode.

Model Mode
  1. To specify the direction data is synchronized, set the directions in the Mapping Direction column as follows:

    • Sales and salesdetail are bi-directional (both upload and download).
    • The remaining tables are download only.
  2. Filter the rows downloaded to the remote database by remote ID:

    1. For the stores table, change the Download Subset to Custom.

    2. Open the Download Subset tab at the bottom of the screen.

    3. The remote ID uniquely identifies a remote database. To filter rows by remote ID, add a restriction to the WHERE clause of the download_cursor script. To do this, type the following search condition in the SQL Expression To Use In The Download Cursor's WHERE Clause text box:

      "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.

    4. Follow these steps for the sales, salesdetail, and discounts tables. Make sure you rename the table in the expression appropriately.

  3. Save the synchronization model.

    The synchronization model is complete and ready to be deployed.

Further reading