1

My Scenario:

I have two applications. First one is a website which is connected to MySQL Database and 2nd one is a Desktop Application which is connected to SQL Server2008 R2 Database. The Desktop application updates records locally and the MySQL database is updated online though the website.

Problem:

Two different databases, how can we update at the spot when changes are made either in MySQL or SQL Database?

What I Want:

Databases should be synchronized to each other (e.g. if changes are made in MySQL then SQL server database should be updated, or if changes are made in SQL Database then MySQL database should be updated)

Could anybody please suggest some code, any idea, or any solution to solve this issue?

3
  • Hello, StackOverflow is for asking questions that do not solicit debate and have definite answers. Commented Jul 3, 2013 at 12:40
  • That being said you could look into using some kind of message queue (NServiceBus RabbitMQ, etc), which is what I did at one of my contracts. Commented Jul 3, 2013 at 12:40
  • You could try replication with triggers - stackoverflow.com/questions/1455018/…. Commented Jul 3, 2013 at 12:41

2 Answers 2

1

Make use of Restful API's to Update information from MS SQL server to MYSQL server.

Sign up to request clarification or add additional context in comments.

Comments

0

One of the first things I would point out is that complete and perfect syncing is not possible. Unfortunately there will be data types that exist in SQL Server that don't exist in MySQL and vice versa.

But assuming the data types are pretty simple and the schemas are similar, here are some options:

  1. Use a service bus. You can write an application that monitors both database systems and when it sees a change, it pushes an object onto the service bus. Listeners to the service bus will see the objects and write them to the appropriate destination.

  2. Use triggers like Alex suggested. SQL Server can have CLR code execute on a trigger. The CLR code could be some C# that writes directly to MySQL. Takes some setup, but it's possible. I've investigated running a process from a trigger in MySQL and all options are ugly. It's possible, but security is a major concern. The idea is that a record is changed, trigger is fired and an external process is run.

  3. Write an application that constantly looks for "diffs" in tables and moves data back and forth. You'll need to modify all tables to make sure there is support for date/time stamps for each record so you can track when a record has "changed".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.