PHP、MySQL:有关如何“同步”的问题两个数据库
注意:我的问题在最后一段。
我有多个文件源被插入到数据库中(称为进程/数据库 A)。这些文件包含相同类型的信息,但格式不同(即不同的列标题、顺序、列数等),但是当进程A将它们放入统一的表中时,就显得美观整洁了。我需要将多个来源的数据插入另一个数据库(进程/数据库 B),但我不确定执行此操作的最佳方法是什么。 DB B 是我们使用的软件的一部分。它不是开源的,但可以建立DB连接。
我们已经让进程 A 启动并运行了一段时间。流程 B 是改进仓库物理工作流程的新流程。我认为既然数据已经在进程A中统一了,在我看来,我应该提取这个统一的数据并将其插入到B中。这将节省我为进程B重新映射所有内容的重复工作。
我的问题是,如果我想要要“同步”这两个数据库,最佳方法是什么?我想,这并不完全是“同步”,因为两个表(只需要引用每个数据库上的一个表)具有不同的列。我看到了这些方法..
检查整个数据库并从 DB A 中提取新数据以插入到 DB B 中。然而,DB B 的行数超过 50K。 DB A 较小且增长缓慢。
让用户输入一个日期,从该日期开始查找要从 A 插入到 B 的新数据行。
- < p>检查DB B 中的最新日期(数据行已注明日期),并相应插入。
你们有什么意见吗?我不太熟悉 MySQL 的处理速度,所以我不确定方法 1 是否是一个好的选择。我也不确定这些类型的任务有哪些约定(如果有)。我想这并不是一件太罕见的事情。但(1)似乎是一种更完整的做事方式。如有任何评论或替代选项,我们将不胜感激。我想将内容保留在 PHP 中,因为它将成为 Web 应用程序的一项功能。蒂亚!
Note: my question is in the last paragraph.
I have multiple sources of files that get inserted into a database (call it process/database A). These files contain the same type of information but in different formats (i.e. different column headers, orders, number of columns, etc.), but when process A puts them into a unified table, and it is nice and neat. I need this data from multiple sources also inserted into another database (process/database B), but I'm not sure what is the best way of doing this. DB B is part of a software we use. It is not open-source, but DB connection can be made.
We already have process A up and running for a while. Process B is something new to improve physical workflow at the warehouse. I think since the data is already unified in process A, it seems to me that I should pull this unified data and insert it into B. This will save me the repetitive work of remapping everything for process B.
My question is, if I want to "sync" these two databases, what would be the optimal approach? It's not exactly "syncing," I suppose, because the two tables (only need to reference one table on each DB) have different columns. I see these approaches..
Check the entire DB's and pull from DB A to insert to DB B for new data. However, DB B has over 50K rows. DB A is much smaller and growing slowly.
Have the user input a date from which to look for new data rows to insert from A to B.
Check the latest date (data rows are dated) in DB B, and insert accordingly.
Do you guys have any inputs? I'm not too familiar with MySQL processing speed, so I'm not sure if approach 1 is a good option. I'm also not sure what some conventions (if any) are for these types of tasks. I imagine it isn't a too-uncommon thing to do. But (1) seems to be a more complete way of doing things. Any comments or alternative options are appreciated. I'd like to keep things in PHP as it will be a feature on a web application. TIA!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用mysql集群
检查一下:http://en.wikipedia.org/wiki/MySQL_Cluster
Use mysql clustering
Check it : http://en.wikipedia.org/wiki/MySQL_Cluster