Viren Ajmera
Viren Ajmera

Reputation: 101

Live sync between SQL Server 2008 R2 and MongoDB with Express

I have created custom script in Express that actually migrates SQL Server database to MongoDB.

But I am facing problems in live syncing between the two databases.

Currently I have added a column updated_by in both the databases.

Then I fetch the latest updated_by row from MongoDb and SQL Server database.

Then I check the date difference and based on it I update my MongoDB database.

There are lots of db tables and I am finding it difficult to identify that, which table is being updated.

Is there any log in SQL Server 2008 R2 that states which table is updated and at what time?

I need a mechanism like, any data update in the db table should immediately sync that rows into my MongoDB.

Any more suggestions on live data syncing is also welcome.

Thanks in advance. :)

Upvotes: 4

Views: 3854

Answers (1)

SAMUEL
SAMUEL

Reputation: 8552

When i have such requirement to Sync between Relational DB say (MYSQL) and Non-Relational DB (Mongodb).

I had followed following steps which may help others in future. and the concept is generally called as Change Data Capture

  1. Capture changes (For MYSQL iam using triggers.)
  2. Transform changes to a suitable changes ie RDBMS to Non RDBMS
  3. Update changes
  4. Remember to sync the structural changes of database and corresponding implementaions.

Following links may help

https://www.flydata.com/blog/what-change-data-capture-cdc-is-and-why-its-important/

Upvotes: 0

Related Questions