Question

Suppose there are some databases: P, S1, S2, S3 etc.

P (publisher) has some tables that need to be replicated (cloned and synchronized) on S1, S2 and S3 (subscribers). The copies of those tables will be read-only. Furthermore, the copies will be referenced (via foreign keys) by some other tables within S1, S2, S3 etc.

For example,

  • P has tables P.O1 and P.O2. S1 will have S1.O1_copy, S1.O2_copy and S1.OTHER, with S1.OTHER referencing S1.O1_copy.

From your experience, it is ok to use SQL Server Transactional Replication (as far as I know, that's a log-based replication) for this scenario? Or should I better use trigger-based replication? Though, I suppose triggers may need to be updated every time a new subscriber (database) is added.

The tables from P that need to be replicated are rarely updated, but the update operation needs to be transactional, to ensure data consistency (any read from a replica should return the latest snapshot of the requested data).

Thank you :)

Was it helpful?

Solution

You can use transactional replication for this. The caveats that I would present all involve initializing or reinitializing a subscriber. When you add an article, the default behavior is to drop the object at the subscriber. If you have tables with foreign keys pointing to the replicated table, that drop will fail. You can work around that of course, but it's something to be aware of.

One other thing: I like to treat subscribed databases as read-only as it cuts down on my backup requirements (i.e. if something happens to the database, I create a new one and re-subscriber rather than restoring a backup of the subscriber). You won't have that luxury here as you're storing novel data at the subscriber.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top