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

SQL Anywhere 10.0.1 » MobiLink - Client Administration » UltraLite Clients » Designing synchronization in UltraLite

Publications in UltraLite Next Page

Table order in UltraLite

By setting the Table Order synchronization parameter you can control the order of synchronization operations. If you want to specify a table order for synchronization, you can use the Table Order parameter programmatically or as part of the ulsync utility during testing. The Table Order parameter specifies the order of tables that are to be uploaded. See Table Order synchronization parameter.

You only need to explicitly set the table order, if your UltraLite database has:

Avoiding synchronization issues with foreign key cycles

Table order is particularly important for UltraLite databases that use foreign key cycles. A cycle occurs when you link a series of tables together such that a circle is formed. However, due to complexities that arise when cycles between the consolidated database and the UltraLite remote differ, foreign key cycles are not recommended.

With foreign key cycles, you should order your tables so that operations for a primary table come before the associated foreign table. A Table Order parameter ensures that the insert in the foreign table will have its foreign key referential integrity constraint satisfied (likewise for other operations like delete).

In addition to table ordering, another method you can use to avoid synchronization issues is to check the referential integrity before committing operations. If your consolidated database is a SQL Anywhere database, set one of the foreign keys to check on commit. This ensures that foreign key referential integrity is checked during the commit phase rather than when the operation is initiated. For example:

create table c (
    id integer not null primary key,
    c_pk integer not null
create table p (
    pk integer not null primary key,
    c_id integer not null,
    foreign key p_to_c (c_id) references c(id)
alter table c
   add foreign key c_to_p (c_pk)
   references p(pk)
   check on commit;

If your consolidated database is from another database vendor, check to see if the database has similar methods of checking referential integrity. If so, you should implement this method. Otherwise, you must redesign table relationships to eliminate all foreign key cycles.

See also