Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » MobiLink - Getting Started » MobiLink Tutorials » Tutorial: Using MobiLink with an Oracle 10g consolidated database

 

Lesson 4: Create the synchronization model

The Create Synchronization Model Wizard takes you through the steps of setting up synchronization between the consolidated database and remote database.

To create a synchronization model

  1. Start Sybase Central.

  2. From the Tools menu, choose MobiLink 11 » Set Up MobiLink Synchronization.

    The Create Synchronization Model Wizard appears.

  3. Type sync_oracle as the name and type the location of your new model.

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

  5. On the Consolidated Database Schema page, connect to the consolidated database:

    1. Click Choose The Consolidated Database.

      The Connect To Consolidated Database window appears.

    2. Select ODBC Data Source Name and choose oracle_cons. Click OK.
    3. If this is the first time the consolidated database has been used by MobiLink, a window appears. It asks if you want to install the MobiLink system setup. Installing the MobiLink system setup adds MobiLink system tables and procedures. Click Yes.

      If you see an error message, ensure that the data source is configured properly.

    4. Once the MobiLink system tables and procedures are added to the consolidated database, the name, user, product and version appear on the page. Click Next.

      The Loading Consolidated Database Schema window appears. The tables from the consolidated database schemas are loaded.

  6. Create a remote schema:

    1. On the Remote Database Schema page, select No, Create A New Remote Database Schema and click Next.
    2. On the New Remote Database Schema page, select the checkboxes for the following tables to include them in the remote schema and then click Next.
      • CUSTOMERS
      • ORDERS
      • ORDER_ITEMS
      • PRODUCT_INFORMATION
  7. Choose and configure the download type:

    1. On the Download Type page, select Timestamp-based Download.

      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.

    2. On the Timestamp Download Options page, select Use Shadow Tables To Hold Timestamp Columns.

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

  8. On the Download Deletes page, specify how to propagate record deletions to remote devices:

    1. To indicate that you want the remote database to download deletes, select Yes.
    2. Select Use Shadow Tables To Record Deletions.

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

  9. On the Download Subset page, specify that the remote database should download only a subset of data from the consolidated database:

    1. Select Yes, Download The Same Data To Each Remote. (In Step 2 of the Model mode lesson, you specify how to download specific data to a remote database by using custom logic.)
  10. On the Upload Conflict Detection page, select No Conflict Detection.

    Many applications require conflict detection, but this tutorial uses no conflict detection.

  11. On the Publication, Script Version and Description page, type sync_oracle_publication as your publication and type sync_oracle_scriptversion as your script version.

    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.

  12. 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:
    • ORDERS and ORDER_ITEMS 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 ORDERS 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:
      "OE"."ORDERS"."SALES_REP_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 salesperson, namely, the representative that has an identifier that equals the remote ID for the database.

  3. Save the synchronization model.

    The synchronization model is complete and ready to be deployed.

Further reading