Contents Index Partitioning rows among remote databases Partitioning with overlaps

MobiLink Synchronization User's Guide
  Synchronization Techniques
    Partitioning rows among remote databases

Disjoint partitioning


Partitioning is controlled by the download_cursor and download_delete_cursor scripts for each table involved in synchronization. These scripts take a single parameter, which is the user name supplied in the call to synchronize.

To partition a table among remote databases

  1. Include in the table definition a column containing the synchronization user name in the consolidated database. You need not download this column to remote databases.

  2. Include a condition in the WHERE clause of the download_cursor and download_delete_cursor scripts requiring this column to match the script parameter.

    The script parameter is represented by a question mark in the script. The user name is the second parameter in the download_cursor script. For example, the following download_cursor script partitions a table named Contact by employee ID.

    SELECT id, contact_name
    FROM Contact
    WHERE last_modified > ?
    AND emp_id = ?

    For more information, see download_cursor cursor event, and download_delete_cursor cursor event.

Example 

The primary key pool tables in the CustDB sample application are used to supply each remote database with its own set of primary key values. This technique is used to avoid duplicate primary keys, and is discussed in Maintaining unique primary keys.

A necessary feature of the method is that primary key-pool tables must be partitioned among remote databases in a disjoint fashion.

One key-pool table is ULCustomerIDPool, which holds primary key values for each user to use when they add customers. The table has three columns:

The download_cursor script for this table is as follows.

SELECT pool_cust_id
FROM ULCustomerIDPool
WHERE last_modified > ?
   AND pool_emp_id = ?

When not using a variable, you should use a join or sub-selection that includes the ? placeholder.

For more information, see Synchronizing customers in the Contact sample, and Synchronizing contacts in the Contact sample.


Contents Index Partitioning rows among remote databases Partitioning with overlaps