From 483f4c87de6f745efd90cd15d52a123d2be42ca9 Mon Sep 17 00:00:00 2001 From: chenson42 Date: Thu, 7 Jan 2010 20:59:48 +0000 Subject: [PATCH] relational routing documentation --- .../basicConfig/basic-configuration.xml | 61 +++++++++++++++++-- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/symmetric/src/docbook/user-guide/basicConfig/basic-configuration.xml b/symmetric/src/docbook/user-guide/basicConfig/basic-configuration.xml index 4a1d9e9863..cc7770162e 100644 --- a/symmetric/src/docbook/user-guide/basicConfig/basic-configuration.xml +++ b/symmetric/src/docbook/user-guide/basicConfig/basic-configuration.xml @@ -314,12 +314,12 @@ values('item', 'corp-2-store', 1, current_timestamp, current_timestamp); ]]> - +
Column Router Sometimes requirements may exist that require data to be routed based on the current value or the old value of a - column on the table that is being routed. Column routers are configured by setting the router_type column on the router table + column in the table that is being routed. Column routers are configured by setting the router_type column on the router table to 'column' and setting the router_expression column to an equality expression that represents the the expected value of the column. @@ -374,11 +374,62 @@ values('corp-2-store','corp', 'store', 'column', 'STORE_ID=:EXTERNAL_ID', curren + - -
+
+ Relational Router + + Sometimes routing decisions need to be made based on data that is not in the current row being synchronized. Consider an + example where an Order table and a OrderLineItem table need to be routed to a specific store. The Order table has a column + named order_id and store_id. A store node has an external_id that is equal to the store_id on the Order table. OrderLineItem, + however, only has a foreign key to its order of order_id. In order to route it to the same desitnation, we need to reference + the master Order record. + + + There are two possible ways to route the OrderLineItem in SymmetricDS. One is to configure the 'subselect' router_type on the router table + and the other is to configure an external_select on the trigger table. + + + A 'subselect' is configured with a router_expression that is a SQL select statement that returns a result set of the node_ids that need routed to. Column tokens can + be used in the SQL expression and will be replaced with row column data. The overhead of using this router type is high because the 'subselect' runs for each row + that is routed. It should not be used for tables that have a lot of rows that are updated. It also has the disadvantage that if the Order master record is deleted, + then no results would be returned and routing would not happen. + + + Consider a table that needs to be routed to all nodes in the target group only when a status column is set to 'OK.' The following + SQL statement will insert a column router to accomplish that. + + + + + When using an external_select on the trigger table, data is captured in the external_data column of the data table when a trigger + fires. This 'external data' can then be used for routing by a router_type of 'column'. The advantage of this approach is that it is very unlikely that the master Order table + will have been deleted at the time any DML accures on the OrderLineItem table. It also is a bit more effcient than the 'subselect' approach, although the triggers produced do run + the extra external_select inline with application database updates. + + + In the following example, the store_id is captured from the Order table in the external_data column. EXTERNAL_DATA is always available for routing as a virtual column in a 'column' + router. The router is configured to route based on the captured EXTERNAL_DATA to all nodes whose external_id matches. Note that other supported node attribute token can also be + used for routing. + + + +
+ +