Partitioning with overlaps

Some tables in your consolidated database may have rows that belong to many remote databases. Each remote database has a subset
of the rows in the consolidated database and the subset overlaps with other remote databases. This is frequently the case
with a customer table. In this case, there is a many-to-many relationship between the table and the remote databases and there
is usually a table to represent the relationship. The scripts for the download_cursor and download_delete_cursor events need
to join the table being downloaded to the relationship table.

This script is fairly complex. It illustrates that the query defining a table in the remote database can include more than
one table in the consolidated database. The script downloads all rows in ULOrder for which the following are all true:

the cust_id column in ULOrder matches the cust_id column in ULEmpCust

the emp_id column in ULEmpCust matches the synchronization user name

the last modification of either the order or the employee-customer relationship was later than the most recent synchronization
time for this user

the status is anything other than Approved

The action column on ULEmpCust is used to mark columns for delete. When NULL, the row is deemed to be fully active (not deleted).