开发者

How do you sync databases using ms sync framework when tables are using identity column and you need to match on an arbitrary key

开发者 https://www.devze.com 2023-03-30 07:11 出处:网络
Sorry for the long and confused title. I have a customer that wants to sync three database.(Later it could be more.)All data in all three databases must sync to the all others.This does not at all ne

Sorry for the long and confused title.

I have a customer that wants to sync three database. (Later it could be more.) All data in all three databases must sync to the all others. This does not at all need to be real time but would probably run nightly or something like that.

This database is using identity columns as primary/foreign keys.

The issue is that a given record could be added independently into two (or even more) of the databases but be the same data. So, for example, I could have a customer name John Smith of 123 Main Street cr开发者_StackOverflow社区eated at both of the site databases. In this case I would want to FirstName LastName and the first 8 characters of the address (or maybe a phone number) to form the "match key" for merging records instead of adding new ones every time. In other words, after all of the syncronization is complete, I would want all 3 database to have just ONE record for John SMith at 123 Main Street.

By the way, the way that I was thinking of doing this is having one "master" database hosted in the cloud. All three databases would do a 2-way sync to this master database.

My main question is how would you get this to work? How do you define the "match key" for tables in the database. Is it as simple as creating unique constraints on the match keys? Is there a way to do it without changing the DB schema? (I am wiling to consider this but I the database is 3rd party and subject to change.)

Seth


if you can add an extra column, create a new column based on the "match key" you specified above. Then configure Sync framework to use that column as the PK and ignoring the actual PKs in the table.

the approach should be similar to this post:

Part 3 – Synchronizing tables where Client and Server Primary Keys are different

0

精彩评论

暂无评论...
验证码 换一张
取 消