Introduction to ACD Replications

ACD (Add, Change, Delete) Replications are a special type of replication that track the operations done against a database rather than replicating the data itself.  When an ACD Replication is defined, a source table is defined and a special ACD target table is created in the target database.  The Event Producer will now monitor the source database for any transactions against the table specified in the ACD Replication and a record will be inserted into the ACD target table specifying each operation (Add, Change or Delete) that occurs for the transaction.  The ACD target table is a transaction log for the specified source table.

ACD Target Table Metadata

The ACD target table consists of all the columns from the source table preceded by five pre-defined columns that provide transaction log information.  The five columns are:

Column Name

Data Type

Description

CNX_ACD_TXID VarChar(64) Transaction ID from source database
CNX_ACD_SequenceNumber

Integer

Sequence number within transaction
CNX_ACD_TimeCreated TimeStamp Timestamp from source database
CNX_ACD_ChangeUser WVarChar(256) User ID that made the change in the source database
CNX_ACD_ChangeType Char(1) Type of change.  Possible values are A,B,C or D

CNX_ACD_TXID

  • This is the transaction ID from the source database.  All operations within a transaction will have the same CNX_ACD_TXID

CNX_ACD_SequenceNumber

  • Each operation within a transaction will have a sequence number denoting its position within a transaction.  For example, if a transaction contains an insert, an update and a delete in that order, the sequence number of the insert will be 1, update will be 2 and the delete will be 3.

CNX_ACD_TimeCreated

  • This is the timestamp from the source database denoting the time the operation occurred.

CNX_ACD_ChangeUser

  • User ID that committed the transaction

CNX_ACD_ChangeType

  • This field indicates the type of operation that occurred (Add, Change or Delete).  There are 4 possible values:
    1. A
      The value A indicates Add.  When a record is inserted into the source table, a record with a change type of A will be inserted into the target ACD table.
    2. B
      The value B indicates the before image key field of an update.  If an update on the source table changes the value of the primary key, the key value in this record will reflect the value prior to the update.  If the key value did not change on the update, a B record will still be created but the value in the key column(s) will be the same as the value(s) in the C record.
    3. C
      The value C indicates the post image record of an update.  When an update occurs on the source table, a C record will be inserted into the target ACD table that contains all the data from the source after the update was completed.
    4. D
      The value D indicates Delete.  When a record is deleted from the source table, a D record is added to the target ACD table that contains the key of the deleted record.

The ACD target target table will be created with a non-unique index on the same column(s) as the primary key or unique index from the source table.  Correct processing of the ACD target table relies on the metadata being known to InstantdbSync.  While indexes may be added to this table to aide in faster retrieval of data, columns should never be added or removed nor should the index that was created with the table be removed.