![]() |
Designing Synchronized Applications
|
|
Publication Design IssuesMaking Targets Small and EfficientBy making each target as small as possible, you may reduce the time required to: Targets without extraneous data are also more secure. To make targets small, whenever possible:
Another technique to make targets small is to put methods in the publication's WHERE clause. This is especially helpful when you don't know beforehand how many parameter values will be passed to the publication. Java collections like Arraylist and Vector provide contains, an especially useful method for this purpose. For example, suppose you want to create a publication like the one defined in Step 4: Describing the Target Data, except that it contains data for multiple salespeople. If you know the number of salespeople whose data you want in the target, you can simply pass it more parameters. For example, if you know that there are three salespeople's data in the target, you can define the publication as follows:
CREATE PUBLICATION toySalesForThreeReps However, if you don't know beforehand how many salespeople will be included in the publication, you cannot know how many parameter to pass to the publication. Using methods in the publication's WHERE clause can solve this problem. The following publication allows you to pass a vector containing any number of salesperson IDs as a parameter to the publication, and the publication will be optimally small:
CREATE PUBLICATION toySalesForMultipleReps NOTE: When using methods in publications, make sure that the method always returns the same results for the same data. A non-deterministic publication can cause incorrect data at a target. A method like contains is safe, but a method that, for instance, calls a random number generator is not. For the same reason, it is advisable not to include SQL-J statements in the method, since a query may return different results at different times. NOTE: Using a method in the WHERE clause to reduce target size may reduce copy publication performance, since it may force a table scan on an indexed column. Target-Side ValidationThe target should "screen" the source from unnecessary transactions. A transaction expected to fail at the source should fail first at the target. Otherwise, a transaction that succeeds at the target may unexpectedly disappear from the target after the refresh completes. For the most part, this screening happens automatically. A WHERE clause of a CREATE PUBLICATION statement becomes a check constraint on a target created from the publication. Therefore, any target transaction that violates the publication's WHERE clause fails at the target and never reaches the source. However, there are cases in which a change at a target may unexpectedly fail at the source and may therefore disappear from the target's user tables after a refresh. Two situations that can cause this are:
// Compensation table. // Everyone either is on commission or gets a year-end bonus CREATE TABLE compensation Handling Published Foreign KeysA foreign key involves two tables. A foreign key constraint may be satisfied on a database but may be violated if parts of the primary or foreign key tables are filtered out by a publication. Since a target database may be a subset of a source database, a foreign key constraint may succeed on the source but fail at the target. If a publication contains a foreign key constraint and incompatible subsets of the two tables' data, it may become impossible to refresh the target without violating the target's foreign key constraint. If this happens, all future refreshes from this target will fail. Once the target is in this state, you must recreate the target with the proper subset of columns and data, or without the foreign key. You can avoid the possibility of targets violating foreign key constraints by following these guidelines when creating publications:
If you create publications that violate these guidelines, be aware that target foreign key constraint violation may occur, and that you may lose the ability to successfully refresh the target. |
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |