MobiLink Synchronization User's Guide
Synchronization Basics
The synchronization process
All MobiLink clients enforce referential integrity when they incorporate the download stream into the remote database.
Rather than failing the download transaction, the MobiLink client automatically deletes all rows that violate referential integrity.
This feature affords you these key benefits.
Protection from mistakes in your synchronization scripts. Given the flexibility of the scripts, it is possible to accidentally download rows that would break the integrity of the remote database. The MobiLink client automatically maintains referential integrity without requiring intervention.
You can use this referential integrity mechanism to delete information from a remote database efficiently. By only sending a delete to a parent record, the MobiLink client will remove all the child records automatically for you. This can greatly reduce the amount of traffic MobiLink must send to the remote database.
The MobiLink client incorporates changes from the download stream in a single transaction. To offer more flexibility, referential integrity checking occurs at the end of this transaction. Because checking is delayed, the database may temporarily pass through states where referential integrity is violated as rows are inserted, updated, and deleted, but the rows that violate referential integrity are automatically removed before the download is committed.
The MobiLink client resolves referential integrity violations automatically. This feature minimizes administration requirements. It also prevents an error in a synchronization script from disabling an MobiLink client.
You can exploit the automatic referential integrity mechanism of MobiLink clients to delete large quantities of information in a very efficient manner. If your MobiLink client contains a primary row, and other rows that reference it, you can delete all the referencing rows simply by synchronizing a delete of the primary row.
Suppose that an UltraLite sales application contains, among others, the following two tables. One table contains sales orders. Another table contains items that were sold in each order. They have the following relationship.
If you use the download_delete_cursor for the sales_order table to delete an order, the automatic referential integrity mechanism automatically deletes all rows in the sales_order_items table that point to the deleted sales order.
This arrangement has the following advantages.
You do not require a sales_order_items script because rows from this table will be deleted automatically.
The efficiency of synchronization is improved. You need not download rows to delete from the sales_order_item table. If each sales order contains many items, the performance improves because the download stream is now smaller. This technique is particularly valuable when using slow communication methods.