简体   繁体   English

PHP,MySQL:有关如何“同步”两个数据库的问题

[英]PHP, MySQL: question on how to “sync” two databases

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). 我有多个插入到数据库中的文件源(称为进程/数据库A)。 These files contain the same type of information but in different formats (ie different column headers, orders, number of columns, etc.), but when process A puts them into a unified table, and it is nice and neat. 这些文件包含相同类型的信息,但格式不同(即,不同的列标题,顺序,列数等),但是当进程A将它们放入统一表中时,它们又好又整洁。 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. 我需要将来自多个源的数据也插入另一个数据库(进程/数据库B)中,但是我不确定执行此操作的最佳方法是什么。 DB B is part of a software we use. DB B是我们使用的软件的一部分。 It is not open-source, but DB connection can be made. 它不是开源的,但是可以建立数据库连接。

We already have process A up and running for a while. 我们已经启动了进程A并运行了一段时间。 Process B is something new to improve physical workflow at the warehouse. 流程B是改善仓库物理工作流程的新方法。 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. 我认为,由于数据已经在流程A中进行了统一,因此在我看来,我应该提取此统一数据并将其插入到B中。这将节省我为流程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.. 我看到了这些方法。

  1. Check the entire DB's and pull from DB A to insert to DB B for new data. 检查整个数据库,并从数据库A中拉出以插入到数据库B中以获取新数据。 However, DB B has over 50K rows. 但是,DB B有超过5万行。 DB A is much smaller and growing slowly. DB A较小,并且增长缓慢。

  2. Have the user input a date from which to look for new data rows to insert from A to B. 让用户输入一个日期,从中寻找要从A插入到B的新数据行。

  3. Check the latest date (data rows are dated) in DB B, and insert accordingly. 检查DB B中的最新日期(数据行标有日期),并进行相应插入。

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. 我对MySQL的处理速度不太熟悉,因此我不确定方法1是否合适。 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. 但是(1)似乎是一种更完整的处理方式。 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. 我希望将其保留在PHP中,因为它将成为Web应用程序的功能。 TIA! TIA!

使用mysql集群进行检查: http : //en.wikipedia.org/wiki/MySQL_Cluster

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM