sql-server - Transfer data between NoSQL and SQL databases on different servers
问题描述
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!
解决方案
(通常)有两种方法可以做到这一点。
- 如果需要立即进行数据传输,您可以使用触发器来完成此操作,但请注意您的错误处理。
- 另一种选择是使用您最喜欢的脚本语言开发某种形式的工作进程并按计划运行。(这将是我的首选,因为我个人对触发器的熟悉程度相当有限)。如果选项 1 不可行,您可以将您的计划设置为非常频繁,例如每分钟一次或每x秒一次,只要在前一个任务完成之前没有产生新任务。
不过,更广泛的问题是,您是否需要在两个不同的来源中复制数据?这种方法的明显缺陷是一致性,如果任何事情失败,您最终可能会导致两个数据源彼此严重不同步,您的方法必须考虑到这一点。
推荐阅读
- flutter - Fitness Scope 使 OAuth 同意屏幕卡在 Flutter 中
- ios - 反应本机图像不渲染
- c++ - 构造线程时会发生什么,以及线程是如何执行的
- java - 如何以 yyyy-MM-dd 格式设置日期,然后在 Java 1.8 中以相同格式打印出来?
- flutter - 长按时手势检测器和滑动
- linux - 无法从脚本自动推送提交
- r - 仅当在 r 中满足条件时,数据帧内的增量计数器
- java - 在 Android Kotlin 的观察者方法中进行网络调用以更新 UI
- google-sheets - 如果值介于 2 个值之间,则过滤公式不显示任何内容 Google 表格
- css - 如何在网格列中居中图像