1

Currently, I'm working on a MERN Web Application that'll need to communicate with a Microsft SQL Server database on a different server but on the same network.

Data will only be "transferred" from the Mongo database to the MSSQL one based on a user action. I think I can accomplish this by simply transforming the data to transfer into the appropriate format on my Express server and connecting to the MSSQL via the matching API.

On the flip side, data will be transferred from the MSSQL database to the Mongo one when a certain field is updated in a record. I think I can accomplish this with a Trigger, but I'm not exactly sure how.

Do either of these solutions sound reasonable or are there more better/industry standard methods that I should be employing. Any and all help is much appreciated!

4

1 回答 1

1

(通常)有两种方法可以做到这一点。

  1. 如果需要立即进行数据传输,您可以使用触发器来完成此操作,但请注意您的错误处理。
  2. 另一种选择是使用您最喜欢的脚本语言开发某种形式的工作进程并按计划运行。(这将是我的首选,因为我个人对触发器的熟悉程度相当有限)。如果选项 1 不可行,您可以将您的计划设置为非常频繁,例如每分钟一次或每x秒一次,只要在前一个任务完成之前没有产生新任务。

不过,更广泛的问题是,您是否需要在两个不同的来源中复制数据?这种方法的明显缺陷是一致性,如果任何事情失败,您最终可能会导致两个数据源彼此严重不同步,您的方法必须考虑到这一点。

于 2018-06-05T13:49:19.100 回答