Chapter 8. SQL Remote Design forAdaptive Ser verEnter prise
4. Replicate the change from the remote to the consolidated database, by
runningthe Message Agent at the remote database to send the message,
andthen at the consolidated database to receive and apply the message.
5. At the consolidated database, view the Customer table and the
ConflictLogtable. TheCustomer table contains the value from the
consolidateddatabase:
cust_key name rep_key
cust1 ConsolidatedSports rep1
TheConflictLog table has a single row, showing the conflict and
recordingthe value entered at the remote database:
conflict_key lost_name won_name remote_user
1 FieldSports ConsolidatedSports field_user
6. Run the Message Agent again at the remote database. Thisreceives the
correctedupdate from the consolidated database, so that the name of the
customeris set to Consolidated Sports here as well.
Designing to avoid referential integrity errors
Thetables in a relational database are related through foreign key references.
Thereferential integrity constraints applied as a consequence of these
referencesensure that the database remains consistent. Ifyou wish to
replicateonly a part of a database, there are potential problems with the
referentialintegrity of the replicated database.
Referentialintegrity errors stop replication
If a remote database receives a message that includes a statement that
cannot be executed because of referential integrityconstraints, nofurther
messagescan be applied to the database (because they come after a message
that has not yet been applied), including passthrough statements, which
wouldsit in the message queue.
Bypaying attention to referential integrity issues while designing
publicationsyou can avoid these problems. Thissection describes some of
themore common integrity problems and suggests ways to avoid them.
Unreplicatedreferenced
tableerrors Considerthe following SalesRepData publication:
exec sp_add_remote_table ’SalesRep’
exec sp_create_publication ’SalesRepData’
exec sp_add_article ’SalesRepData’, ’SalesRep’
go
173