Data synchronization method, electronic equipment and storage medium

By performing consistency checksum comparison between databases, the data inconsistency caused by system failures during data transmission is solved, ensuring the consistency of data during change, thereby improving production quality and efficiency.

CN118939734AInactive Publication Date: 2024-11-12ZHEJIANG DAHUA TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411425176.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2024-11-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

During the data transfer process between databases, data packet loss caused by system power down, network interruption, etc., the changes in the data table cannot be synchronized, resulting in data inconsistency, affecting product production quality and production efficiency.

Method used

Before making data changes, the data to be changed in the source database and the target database are checked for consistency. By obtaining historical project change records and change time, data comparison and synchronization are performed to ensure the consistency of the data in different databases.

Benefits of technology

It effectively ensures the consistency of data when changes are made, improves product production quality and production efficiency, and avoids production problems caused by inconsistent data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939734A_ABST
    Figure CN118939734A_ABST
Patent Text Reader

Abstract

The invention discloses a data synchronization method, electronic equipment and a storage medium, and the method comprises the steps: obtaining to-be-changed first data in a source database and a historical engineering change of the first data, the historical engineering change being a historical engineering change adjacent to the current time; obtaining a first change time and a change record of the historical engineering change to the first data, and a second change time of the target database to the first data, the second change time being a change time adjacent to the current time in the target database; in response to mismatching between the first change time and the second change time, performing change comparison on the first data in the target database by using the change record; changing the target database which is not matched with the change comparison according to the change record; according to the method, before the current change is carried out, the to-be-changed first data is verified in the source database and the target database, so that the consistency of the first data in different databases can be effectively ensured, and the production quality of related products is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data transmission between databases, and in particular to a data synchronization method, electronic device and storage medium. Background Art

[0002] With the explosive growth of computer applications, the requirements for data management are becoming increasingly higher, especially for the data management of production materials. During the entire life cycle of a product, the data composition of its materials will be continuously iterated and updated for various reasons. In order to ensure the accuracy and consistency of product data, the PLM system (Product Lifecycle Management) is usually used as the source database to uniformly manage product data. After the product's material data list is changed, it is updated to the latest data table through the change process, and the command is triggered to uniformly send the updated data table to other databases to ensure the accuracy and consistency of data between systems.

[0003] In practice, with the development of business, the instructions of change processes with time intersection are becoming more and more intensive, and the amount of data is increasing, which makes the cross-system data table changes more and more. In addition, due to the loss of data packets caused by occasional reasons such as system power off and network interruption during the transmission process, the changes in the data table cannot be synchronized to other systems, resulting in inconsistencies in the data between the source database and other databases, which in turn affects the production quality and efficiency of the product. Summary of the invention

[0004] The main technical problem solved by the present application is to provide a data synchronization method, an electronic device and a storage medium. Before making any changes, a consistency check is performed on the data to be changed in the source database and the target database, which can effectively ensure the consistency of the data to be changed when making the change, thereby improving the production quality and efficiency of the product.

[0005] To solve the above technical problems, a technical solution adopted in the present application is: providing a data synchronization method, including: obtaining first data to be changed in a source database and historical engineering changes of the first data, wherein the historical engineering changes are historical engineering changes close to the current time; obtaining a first change time and change record of the historical engineering changes to the first data, and a second change time of the first data to the target database, wherein the second change time is a change time in the target database close to the current time; in response to a mismatch between the first change time and the second change time, using the change record to perform a change comparison on the first data in the target database; and changing the changes in the target database that do not match the comparison according to the change record.

[0006] In some embodiments, the obtaining of the first data to be changed in the source database and the historical engineering changes of the first data includes: taking the data to be changed in the source database as the first data, and recording the current change of the first data as the current engineering change, and recording the current time of the current engineering change; retrieving the source database historical change record of the first data in the source database, and taking the historical changes adjacent to the current time as the historical engineering changes, and recording the first change time of the historical engineering change.

[0007] In some embodiments, obtaining the first change time and change record of the historical engineering change to the first data, and the second change time of the target database to the first data, includes: obtaining the first change time of the historical engineering change to the first data and the corresponding first change record from the historical change record of the source database; retrieving the target database historical change record of the first data in the target database, and recording the second change time of the target database to the first data.

[0008] In some embodiments, in response to the mismatch between the first change time and the second change time, a change comparison is performed on the first data in the target database using the first change record, including: obtaining a data addition set, a data deletion set, and a data modification set involving the first data in the historical engineering change, and determining the first change record with the data addition set, the data deletion set, and the data modification set; in response to the mismatch between the first change time and the second change time, a change comparison is performed on the first data in the target database using the data addition set, the data deletion set, and the data modification set, respectively.

[0009] In some embodiments, it also includes: obtaining the addition set index number of the data addition set, obtaining the deletion set index number of the data deletion set, and obtaining the modification set index number of the data modification set; in response to the mismatch between the first change time and the second change time, using the data addition set, the data deletion set and the data modification set to respectively perform a change comparison on the first data in the target database, including: using the addition set index number to retrieve the first content of the first data in the target database corresponding to the addition set index number, and performing a change comparison between the first content and the data addition set in the source database to obtain a first comparison result; using the deletion set index number to retrieve the second content of the first data in the target database corresponding to the deletion set index number, and performing a change comparison between the second content and the data deletion set in the source database to obtain a second comparison result; using the modification set index number to retrieve the third content of the first data in the target database corresponding to the modification set index number, and performing a change comparison between the third content and the data modification set in the source database to obtain a third comparison result.

[0010] In some embodiments, the change comparison of the target database that does not match the data is changed according to the change record, including: in the first comparison result, when the first content is inconsistent with the data addition set in the source database, the data addition set in the source database is added to the first data of the target database; in the second comparison result, when the second content is inconsistent with the data deletion set in the source database, the content in the target database corresponding to the deletion set index number is deleted; in the third comparison result, when the third content is inconsistent with the data modification set in the source database, the data modification set in the source database is modified to the target database.

[0011] In some embodiments, it also includes: in response to the first change time and the second change time matching, obtaining a first data form corresponding to the first data at the current time in the source database; searching the source database to see whether there is a waiting change for the first data; if there is a waiting change, extracting the change content in the waiting change, and comparing the change content with the content of the first data form, and executing the change of the change content on the first data form based on the comparison result.

[0012] In some embodiments, the changed content includes added content, deleted content and modified content; when there is a waiting change, the changed content in the waiting change is extracted, and the changed content is compared with the content of the first data form, and the change of the changed content is executed on the first data form based on the comparison result, including: using the added content to compare with the content of the first data form, when the content of the first data form does not match the added content, using the added content to add in the first data form of the source database; using the deleted content to compare with the content of the first data form, when the content of the first data form matches the deleted content, using the deleted content to delete in the first data form of the source database; using the modified content to compare with the content of the first data form, when the content of the first data form matches the modified content, using the modified content to modify in the first data form of the source database; and synchronizing the execution of the change of the changed content to the target database.

[0013] To solve the above technical problems, another technical solution adopted in the present application is: to provide an electronic device, the electronic device comprising a memory and a processor coupled to the memory, the memory storing at least one computer program, and the at least one computer program, when loaded and executed by the processor, is used to implement the above data synchronization method.

[0014] To solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium, wherein the computer-readable storage medium has at least one program, and when the at least one program is loaded and executed by the processor, it is used to implement the above data synchronization method.

[0015] Different from the current technology, the data synchronization method provided by the present application includes: obtaining the first data to be changed in the source database and the historical engineering changes of the first data, wherein the historical engineering changes are historical engineering changes close to the current time; obtaining the first change time and change record of the historical engineering changes to the first data, and the second change time of the first data to the target database, wherein the second change time is the change time in the target database close to the current time; in response to the mismatch between the first change time and the second change time, using the change record, performing a change comparison on the first data in the target database; changing the change comparison that does not match the target database according to the change record; that is, in the present application, before making the current change, performing a consistency check on the first data that needs to be changed in the source database and the target database, which can effectively ensure the consistency of the first data that needs to be changed in different databases, thereby improving the production quality and production efficiency of the product. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them: Figure 1 It is a flowchart of an embodiment of a data synchronization method in the present application; Figure 2 It is a schematic diagram of the operation flow of data verification in this application; Figure 3 It is a flow chart of the change principle in this application; Figure 4 It is a structural diagram of an embodiment of a data synchronization system in the present application; Figure 5 It is a structural schematic diagram of an embodiment of an electronic device in the present application; Figure 6 It is a structural diagram of an embodiment of a computer-readable storage medium in the present application. DETAILED DESCRIPTION

[0017] The present invention will be further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present invention, but are not intended to limit the scope of the present invention. Similarly, the following examples are only partial embodiments of the present invention rather than all embodiments, and all other embodiments obtained by those of ordinary skill in the art without creative work are within the scope of protection of the present invention.

[0018] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0019] Traditional data synchronization methods usually establish data connection information between the source database and the target database, and set up a monitoring tool in the target database. After the source database sends a data change operation, the change information of the source database is obtained through the monitoring tool, and the changed data is synchronized to the target database. However, after the connection is disconnected, the data cannot be synchronized, and the problem of how to synchronize a large number of data changes after the subsequent connection is restored has not been solved; or a data change process is initiated in the source database, and the changes in the source database are recorded in the change process. After the change process is completed, the changes in the source database are synchronized to the target data in the target database through triggering behavior. However, when the connection is disconnected and the data cannot be synchronized, the source database data has been changed, but the target database data has not received the data change content, resulting in inconsistency between the source database and the target database data, and there is no opportunity for re-synchronization.

[0020] Therefore, a data synchronization method is provided. Before making the current change, a consistency check is performed on the first data that needs to be changed in the source database and the target database, which can effectively ensure the consistency of the first data that needs to be changed in different databases, thereby improving the production quality and production efficiency of the product.

[0021] See also Figure 1 , Figure 1 is a flow chart of an embodiment of the data synchronization method in the present application; it should be noted that if there is a substantial result, the method of the present application is not based on Figure 1 The process sequence shown is limited.

[0022] like Figure 1 As shown, the data synchronization method includes the following steps.

[0023] S10. Acquire first data to be changed and historical engineering changes of the first data in a source database, wherein the historical engineering changes are historical engineering changes close to the current time.

[0024] The source database refers to the data source that provides the original data, the first data to be changed refers to the data that needs to be changed at the current time, and the historical engineering change refers to the change that has appeared in the historical change record for the first data.

[0025] Specifically, the data waiting to be changed in the source database is taken as the first data to be changed, and the historical change records of the first data are retrieved, and the historical change closest to the current time is taken as the historical engineering change of the first data.

[0026] S20, obtaining a first change time and change record of a historical engineering change on the first data, and a second change time of the target database on the first data, wherein the second change time is a change time in the target database that is close to the current time.

[0027] Among them, the first change time refers to the time corresponding to the historical engineering change of the first data in the source database; the change record refers to the data change record corresponding to the change of the first data by the historical engineering change; the target database refers to other databases corresponding to the source database, that is, the data in the source database needs to be synchronized to the target database; the second change time refers to the time corresponding to the target database executing the change on the first data, that is, the second change time is the change time in the target database that is close to the current time, that is, the second change time is the last change time in the target database.

[0028] Specifically, after obtaining the historical engineering change of the first data, a first change time of the historical engineering change on the first data and a change record of the corresponding changed data are recorded; and a second change time of the change on the first data in the target database is obtained.

[0029] S30: In response to the first change time not matching the second change time, using the change record to perform a change comparison on the first data in the target database.

[0030] Among them, the first change time corresponds to the time corresponding to the historical engineering change of the first data in the source database, and the second change time corresponds to the time corresponding to the change of the first data in the target database; the first change time and the second change time do not match, indicating that the source database and the target database make changes at different times. Therefore, the data in the source database and the first data in the target database are also different. Therefore, it is necessary to perform a change comparison of the first data.

[0031] Specifically, after obtaining the first change time corresponding to the source database and the second change time corresponding to the target database, the first change time and the second change time are compared and matched. When the first change time and the second change time do not match, the change record corresponding to the source database is used to perform a change comparison on the first data in the target database to determine the matching status of the first data in the source database and the first data in the target database.

[0032] S40, the unmatched changes in the target database are changed according to the change records.

[0033] Among them, the comparison mismatch refers to the existence of differences between the first data in the target database and the first data in the source database, for example, there is addition of data, deletion of data and / or modification of data, etc., which results in the first data in the source database being changed, while the first data in the target database has not been changed, and the corresponding change situations are different, resulting in differences in the first data.

[0034] Specifically, after using the change records corresponding to the historical engineering changes to compare the changes of the first data in the target database, determine the matching situation of the first data in the source database and the first data in the target database. When the change comparison of the first data in the target database and the first data in the source database does not match the change comparison, the unmatched data in the target database is changed according to the change records corresponding to the historical engineering changes, so that the changes in the target database are consistent with the changes in the source database, thereby ensuring the consistency and accuracy of the first data in the target database and the first data in the source database.

[0035] In this embodiment, before making the current change, a consistency check is performed on the first data that needs to be changed in the source database and the target database. When there is an inconsistency, the change record corresponding to the source database is used to change the non-matching content of the target database, which can effectively ensure the consistency of the data that needs to be changed in the source database and the target database, that is, ensure the consistency of the first data in different databases when making the current change, thereby improving the production quality and efficiency of the product.

[0036] In some embodiments, step S10 obtains first data to be changed and historical engineering changes of the first data in a source database, wherein the historical engineering changes are historical engineering changes close to the current time, and may include the following operation steps.

[0037] First, the data to be changed in the source database is taken as the first data, and the current change of the first data is recorded as the current engineering change, and the current time of the current engineering change is recorded.

[0038] Among them, the source database can be a source data system that provides a data source, and the data waiting to be changed at the current time in the source data system is the first data, and then the current change that needs to be made to the first data is recorded as the current engineering change, and the creation time of the current engineering change is determined, that is, the current time.

[0039] Next, the source database historical change records of the first data in the source database are retrieved, and the historical changes adjacent to the current time are taken as historical engineering changes, and the first change time of the historical engineering changes is recorded.

[0040] Among them, before making the current engineering change, it is necessary to retrieve the historical change records of the first data in the source database to determine the historical change closest to the current change; the first change time is the time when the historical engineering change executes the change on the first data, corresponding to the creation time of the historical engineering change.

[0041] Specifically, after determining the current engineering change, the historical change record of the source database of the first data in the source database is retrieved, and the historical change closest to the current time is used as the historical engineering change corresponding to the current engineering change, and the first change time when the historical engineering change executes the change on the first data is recorded; the above scheme directly obtains the historical engineering change closest to the current time, which can effectively avoid the problem of data confusion caused by the superposition of multiple changes to the same data.

[0042] In some embodiments, step S20 of obtaining the first change time and change record of the historical engineering change to the first data, and the second change time of the target database to the first data, may include the following operation steps.

[0043] First, a first change time of a historical engineering change on first data and a corresponding change record are obtained from the historical change record of the source database.

[0044] The source database historical change record is the change process stored in the source database for historical changes to data.

[0045] Specifically, the first change time of the first data changed by the historical engineering change and the specific change content of the first data changed by the historical engineering change, that is, the change record of the source database, can be directly obtained from the historical change record of the source database.

[0046] The target database historical change record of the first data in the target database is retrieved, and a second change time of the first data in the target database is recorded.

[0047] Among them, the target database is a database other than the source database, that is, a database that needs to be synchronized with the data of the source database; the historical change record of the target database is the historical record of changes to the first data in the target database that is closest to the current time; the second change time is the time when the change to the first data in the target database is closest to the current time.

[0048] Specifically, the second change time when the target database changes the first data and the specific change content of the target database changing the first data, that is, the change record of the target database, can be directly obtained from the historical change record of the target database.

[0049] In this embodiment, a first change time when the source database changes the first data and a second change time when the target database changes the first data are obtained respectively, to provide a basis for subsequent matching and to clarify whether the change of the first data by the source database is the same as the change of the first data by the target database.

[0050] In some embodiments, step S30, in response to the mismatch between the first change time and the second change time, using the change record to perform a change comparison on the first data in the target database may include the following operation steps.

[0051] First, a data addition set, a data deletion set, and a data modification set involving the first data in the historical engineering change are obtained, and the change record is determined by the data addition set, the data deletion set, and the data modification set.

[0052] Among them, the data addition set is a set of added data for the first data in historical engineering changes, the data deletion set is a set of deleted data for the first data in historical engineering changes, and the data modification set is a set of modified data for the first data in historical engineering changes.

[0053] Specifically, for the historical engineering changes to the first data in the source database, the added content of the first data in the historical engineering changes is obtained as a data addition set, the deleted content of the first data in the historical engineering changes is obtained as a data deletion set, and the modified content of the first data in the historical engineering changes is obtained as a data modification set, and the change record of the historical engineering changes to the first data is determined by the data addition set, data deletion set and data modification set.

[0054] Next, in response to the mismatch between the first change time and the second change time, a change comparison is performed on the first data in the target database using the data addition set, the data deletion set and the data modification set.

[0055] Among them, the first change time and the second change time do not match, which means that the historical engineering change closest to the current time in the source database and the change closest to the current time in the target database are not the same change. Therefore, the first data in the source database is not the same as the first data in the target database, and the change records need to be compared.

[0056] Specifically, after obtaining the first change data of the source database and the second change time of the target database, in response to the mismatch between the first change time and the second change time, the data addition set, the data deletion set and the data modification set are directly used to perform change comparison on the first data in the target database to determine the differences between the first data in the target database and the first data in the source database.

[0057] Furthermore, a corresponding index number may be obtained and compared using the index number, which may specifically include the following steps.

[0058] Get the added set index number of the data added set, get the deleted set index number of the data deleted set, and get the modified set index number of the data modified set.

[0059] Among them, the addition set index number is the index number of the added data involved in the first data in the historical engineering change of the source database, which is convenient for determining the data added by the data addition set; the deletion set index number is the index number of the deleted data involved in the first data in the historical engineering change of the source database, which is convenient for determining the data deleted by the data deletion set; the modification set index number is the index number of the modified data involved in the first data in the historical engineering change of the source database, which is convenient for determining the data modified by the data modification set.

[0060] The first content of the first data corresponding to the increase set index number in the target database is retrieved by using the increase set index number, and the first content is compared with the data increase set in the source database to obtain a first comparison result.

[0061] Specifically, the first content of the first data in the target database corresponding to the added set index number is retrieved using the added set index number, that is, it is determined whether there is corresponding added data in the target database corresponding to the added set index number, so as to determine the first comparison result of the first content of the target database with the content of the added set of the source database data.

[0062] The deletion set index number is used to retrieve the second content of the first data corresponding to the deletion set index number in the target database, and the second content is compared with the data deletion set in the source database to obtain a second comparison result.

[0063] Specifically, the deletion set index number is used to retrieve the second content of the first data in the target database corresponding to the deletion set index number, that is, to determine whether there is corresponding deletion data in the target database corresponding to the deletion set index number, so as to determine the second comparison result of the deletion comparison between the second content of the target database and the content of the source database data deletion set.

[0064] The modification set index number is used to retrieve the third content of the first data in the target database corresponding to the modification set index number, and the third content is compared with the data modification set in the source database to obtain a third comparison result.

[0065] Specifically, the modification set index number is used to retrieve the third content of the first data in the target database corresponding to the modification set index number, that is, to determine whether there is corresponding modification data in the target database corresponding to the modification set index number, so as to determine the third comparison result of the modification comparison between the third content of the target database and the content of the modification set of the source database data.

[0066] In this embodiment, the change comparison result between the first data in the source database and the first data in the target database is determined through the data addition set and the corresponding addition set index number, the data deletion set and the corresponding deletion set index number, the data modification set and the corresponding modification set index number, that is, it is determined whether there are differences between the first data in the source database and the first data in the target database. If there are differences, the first data in the target database can be subsequently changed based on the data addition set, the data deletion set, the data modification set and their corresponding index numbers, so that the first data in the source database and the first data in the target database remain consistent.

[0067] In some embodiments, step S40 changes the target database changes that do not match the comparison according to the change record, which may include the following operation steps.

[0068] In the first comparison result, when the first content is inconsistent with the data addition set in the source database, the data addition set in the source database is supplemented to the first data in the target database.

[0069] The first content is inconsistent with the data addition set in the source database, that is, the first content corresponding to the addition set index number in the target database is missing, so it needs to be supplemented with the content corresponding to the addition set index number in the source database.

[0070] Specifically, if the first content in the first comparison result is inconsistent with the data addition set in the source database, the first content corresponding to the added set index number of the target database is supplemented according to the content corresponding to the added set index number in the source database, so that the content corresponding to the added set index number in the target database is consistent with the content corresponding to the added set index number in the source database; if the first content in the first comparison result is consistent with the data addition set in the source database, the operation of the second comparison result is performed.

[0071] In the second comparison result, when the second content is inconsistent with the data deletion set in the source database, the content corresponding to the deletion set index number in the target database is deleted.

[0072] The second content is inconsistent with the data deletion set in the source database, that is, there is still content with the deletion set index number in the target database and needs to be deleted.

[0073] Specifically, if the second content is inconsistent with the data deletion set in the source database, the content corresponding to the deletion set index number in the target database will be cleared so that the content corresponding to the deletion set index number in the target database is consistent with the content corresponding to the deletion set index number in the source database; if the second content in the second comparison result is consistent with the data deletion set in the source database, the third comparison result operation will be performed.

[0074] In the third comparison result, when the third content is inconsistent with the data modification set in the source database, the data modification set in the source database is modified to the target database.

[0075] Among them, the third content is inconsistent with the data modification set in the source database, that is, the target database has not been modified, and it is necessary to modify it according to the content corresponding to the modification set index number.

[0076] Specifically, if the third content is inconsistent with the data modification set in the source database, the content corresponding to the modification set index number in the source database is modified to the target database.

[0077] In this embodiment, the change comparison result between the first data in the source database and the first data in the target database is determined through the data addition set and the corresponding addition set index number, the data deletion set and the corresponding deletion set index number, the data modification set and the corresponding modification set index number, that is, it is determined whether there are differences between the first data in the source database and the first data in the target database, and if there are differences, the first data in the target database can be changed based on the data addition set, the data deletion set, the data modification set and their corresponding index numbers, so that the first data in the source database and the first data in the target database remain consistent, that is, the data consistency work of the source database and the target database is completed.

[0078] The work of verifying data consistency before the change is now completed. In order to make the data verification process clearer, the following describes the data verification principle process.

[0079] See also Figure 2 , Figure 2 It is a schematic diagram of the operation flow of data verification in this application.

[0080] like Figure 2As shown, Y101, obtain the first data to be changed and its first engineering change in the source database; Y102, obtain the historical engineering change and the first change time of the first data, wherein the historical engineering change is the historical change record closest to the current time, that is, find the historical change record closest in time in the historical change record of the first data as the historical engineering change, and record the creation time of the second engineering change; Y103, obtain the change set involving the first data in the second engineering change, including a data addition set, a data deletion set and a data modification set; that is, retrieve the materials involved in the change of the first data in the second engineering change, record the newly added change materials as the data addition set, record the deleted change materials as the data deletion set, and record the modified change materials as the data modification set. is a data modification set; Y104, obtain the index number of each change set; that is, record the data addition set / data deletion set index number, record the data modification set index number and the modified column number and content in the index row; Y105, obtain the second change time of the first data in the target database, and judge whether the first change time and the second change time are consistent, that is, for the first data appearing in the historical engineering change, retrieve the data change time of the first data form in the target database, record it as the data synchronization time, compare the historical engineering change creation time with the data synchronization time, if the two are inconsistent, go to step Y106, otherwise go to step Y1012; Y106, according to the increase set index number, judge whether the data increase set content corresponding to the source database and the target database is If the content of the added set index number row of the first data in the target database is consistent, that is, the content of the added set index number row of the first data in the source database is retrieved, and it is determined whether its content is consistent with the content of the added set index number row of the first data in the source database; if they are consistent, it goes to step Y107, otherwise it goes to step Y109; Y107, according to the deletion set index number, it is determined whether the content of the data deletion set corresponding to the source database and the target database is consistent, that is, the content of the deletion set index number row of the first data in the target database is retrieved, when the deletion set index number row has no content, the data is expressed to be correct, and it is transferred to step Y108, when there is content, it is transferred to step Y110; Y108, according to the modification set index number, it is determined whether the content of the data modification set corresponding to the source database and the target database is consistent, that is, the modification set of the first data in the target database is retrieved. Modify the content of the index number row, and determine whether the content of the modified column of the index row is consistent with that in the source database. If they are consistent, it means that the data is correct and go to step Y109; if they are inconsistent, go to step Y111; Y109, use the data increase set to supplement the target database, that is, when the content of the increase set index number row is inconsistent, the system determines the first data missing row in the target database, and supplements it according to the content of the first data increase set index number row in the source database, and records this change time as the second engineering change synchronization time; Y110 uses the data deletion set to delete the target database, that is, when the content of the deletion set index number row is inconsistent, the content of the deletion set index number row in the target database is cleared, and the change time is recorded as the second engineering change synchronization time;Y111. Use the data modification set to modify the target database. That is, when the content of the modification set index number row is inconsistent, the system compares the inconsistent column number content of the modification set index number row, modifies the relevant data of the source database to the target database, and records this change time as the second engineering change synchronization time; Y112. Complete the data consistency work of the source database and the target database. ;

[0081] In some embodiments, in response to the first change time and the second change time matching, then: In response to the first change time matching the second change time, a first data form corresponding to the first data at the current time in the source database is obtained.

[0082] Among them, if the first change time and the second change time match, it means that the change of the source database is consistent with the change of the target database, that is, the first data in the source database and the first data in the target database are saved consistently; then the first data form obtained at this time is a data form consistent with the source database and the target database.

[0083] Next, the source database is searched to see whether the first data exists and is waiting to be changed.

[0084] Specifically, after the aforementioned data consistency work is approved, before the current time is changed, it is necessary to search the source database for the waiting changes of the first data to determine whether waiting is required.

[0085] When there is a waiting change, the change content in the waiting change is extracted, and the change content is compared with the content of the first data form, and the change content is changed on the first data form according to the comparison result.

[0086] Among them, for the current change at the current time, the specific content of the current change needs to be determined, so the change content needs to be compared with the content of the first data form.

[0087] Specifically, if waiting for changes is required, the change content in the waiting change needs to be obtained, and the change content at the current time is compared with the content corresponding to the first data form to determine the comparison result that needs to be changed, and then the change content is changed to the first data form based on the comparison result.

[0088] In this embodiment, with respect to changes to a data form, the specific content that needs to be changed is determined, and then the corresponding content in the data form is changed without changing the entire data form, which can effectively save change time and improve change efficiency.

[0089] Furthermore, changes include adding content, deleting content and modifying content; then: First, the added content is compared with the content of the first data form. When the content of the first data form does not match the added content, the added content is added to the first data form of the source database.

[0090] Among them, the added content is the content to be added by the current change, such as added materials. In order to avoid duplicate addition, it is necessary to compare the added content with the content of the first data form. Only when the first data form does not have the data corresponding to the added content, the added content is added to the first data form of the source database.

[0091] Specifically, the added content is compared with the content of the first data form of the source database at the current time. When the content of the first data form does not match the added content, that is, when there is no identical data as the added content in the first data form of the source database, the added content is added to the first data form of the source database; otherwise, the change stops.

[0092] Next, the deleted content is compared with the content of the first data form. When the content of the first data form matches the deleted content, the deleted content is deleted in the first data form of the source database.

[0093] The deleted content is the content to be deleted by the current change.

[0094] Specifically, the deleted content is compared with the content of the first data form of the source database at the current time. When the deleted content can be found in the first data form, the first data form of the source database is deleted using the deleted content; otherwise, the change stops.

[0095] Next, the modified content is compared with the content of the first data form. When the content of the first data form matches the modified content, the modified content is used to make modifications in the first data form of the source database.

[0096] The modified content refers to the content to be modified by the current change.

[0097] Specifically, the deleted content is compared with the content of the first data form of the source database at the current time, and the content data before modification and the content data after modification are recorded. When the content of the first data form is the content data before modification, the modified content is used to modify the first data form in the source database. When the content of the first data form is the content data after modification, the change stops.

[0098] Then, the changes to the execution content are synchronized to the target database.

[0099] The changes of the changed contents are executed in the source database. After the source database and the target database are connected, the changes of the changed contents can be directly synchronized to the target database so that the data in the source database and the target database are consistent.

[0100] In order to make the change process clearer, the following is an illustration.

[0101] See also Figure 3 , Figure 3 It is a flow chart of the change principle in this application.

[0102] like Figure 3 As shown, the following steps are included: Y201, obtaining the first data form corresponding to the first data in the source database, wherein, based on the first data form, the system extracts the index row number of the operation record, and classifies it according to added content, deleted content, and modified content; Y202, searching the source database to see whether there is any waiting change for the first data, if so, enter the waiting change, otherwise, execute the change of the change content, that is, when the change process is approved and completed, the waiting change of the first data is searched in the source database, when there is no waiting change for the first data, the system executes the change operation; when the first data has a waiting change, it goes to step Y203; Y203, using the added content to add, that is, for the addition operation, the system extracts the material numbers in the added index row, and compares them with the material numbers in each row in the original first data form. When there is no identical material number, the system executes Perform this part of the change operation, otherwise the change is terminated; Y204, delete using the deletion content, that is, for the deletion operation, the system extracts the material numbers in the deletion index row, and compares them with the material numbers in the original first data form. When the material numbers in the deletion index row can be retrieved in the first data form, the system executes this part of the change operation, otherwise the change is terminated; Y205, modify using the modification content, that is, for the modification operation, the system extracts the material numbers in the modification index row, and records the column number of the changed column in the modification row and the content data before and after the change, and the system executes this part of the change operation; Y206, execute the change of the change content; Y207, synchronize the change of the execution change content to the target database, that is, export the data content of adding index rows, deleting index rows, and modifying index row numbers of the first data to the target database, and execute the change.

[0103] In this embodiment, before making the current change, a consistency check is performed on the first data that needs to be changed in the source database and the target database. When there is an inconsistency, the change record corresponding to the source database is used to change the non-matching content of the target database, which can effectively ensure the consistency of the data that needs to be changed in the source database and the target database, that is, ensure the consistency of the first data in different databases when making the current change, thereby improving the production quality and efficiency of the product.

[0104] In some embodiments, a data synchronization system is also provided.

[0105] See also Figure 4 , Figure 4 It is a structural diagram of an embodiment of a data synchronization system in the present application.

[0106] like Figure 4 As shown, the data synchronization system 400 includes a first acquisition module 410, a second acquisition module 420, a comparison module 430 and a change module 440; wherein the first acquisition module 410 is used to acquire the first data to be changed in the source database and the historical engineering changes of the first data, wherein the historical engineering changes are historical engineering changes close to the current time; the second acquisition module 420 is used to acquire the first change time and change record of the historical engineering changes to the first data, and the second change time of the first data in the target database, wherein the second change time is the change time in the target database close to the current time; the comparison module 430 responds to the mismatch between the first change time and the second change time, and uses the change record to perform a change comparison on the first data in the target database; the change module 440 is used to change the changes in the target database that do not match the comparison according to the change record.

[0107] In some embodiments, an electronic device is also provided.

[0108] See also Figure 5 , Figure 5 1 is a schematic diagram of the structure of an electronic device in an embodiment of the present application. The electronic device can execute the data synchronization step in the above method.

[0109] The electronic device 500 includes a memory 520, a processor 510 coupled to the memory, and at least one computer program stored in the memory 520 and executable on the processor 510; when the processor 510 loads and executes the at least one computer program, it is used to implement the data synchronization steps in the above method. For related content, please refer to the detailed description in the above method, which will not be repeated here.

[0110] In some embodiments, a computer-readable storage medium is also included.

[0111] See also Figure 6 , Figure 6 It is a structural diagram of an embodiment of a computer-readable storage medium in the present application.

[0112] The computer readable storage medium 600 stores at least one program 610, which is used to implement the data synchronization step in the above method when loaded and executed by the processor. For related contents, please refer to the detailed description of the above method, which will not be repeated here.

[0113] In the above scheme, before the source database and the target database need to make data changes, in order to ensure data consistency, before making the current change, the first data that needs to be changed is checked for consistency in the source database and the target database. When there is an inconsistency, the change record corresponding to the source database is used to change the non-matching content in the target database, which can effectively ensure the consistency of the data that needs to be changed in the source database and the target database, that is, ensure the consistency of the first data in different databases when making the current change, thereby improving the production quality and efficiency of the product.

[0114] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0115] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0116] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0117] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0118] The above description is only an implementation mode of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A data synchronization method, It is characterized in that include: Acquire first data to be changed and historical engineering changes of the first data in a source database, wherein the historical engineering changes are historical engineering changes close to the current time; Acquire a first change time and change record of the historical engineering change on the first data, and a second change time of the target database on the first data, wherein the second change time is a change time in the target database that is close to the current time; In response to the first change time and the second change time not matching, using the change record to perform a change comparison on the first data in the target database; Changes in the target database that do not match the comparison are changed according to the change record.

2. The data synchronization method according to claim 1, It is characterized in that The obtaining of first data to be changed and historical engineering changes of the first data in the source database includes: The data to be changed in the source database is taken as the first data, and the current change of the first data is recorded as the current engineering change, and the current time of the current engineering change is recorded; The source database historical change records of the first data in the source database are retrieved, and the historical changes adjacent to the current time are taken as historical engineering changes, and the first change time of the historical engineering changes is recorded.

3. The data synchronization method according to claim 2, It is characterized in that The obtaining of the first change time and change record of the historical engineering change to the first data, and the second change time of the target database to the first data, includes: Acquire the first change time of the historical engineering change on the first data and the corresponding change record from the historical change record of the source database; The target database historical change record of the first data in the target database is retrieved, and a second change time of the first data in the target database is recorded.

4. The data synchronization method according to claim 1, It is characterized in that In response to the first change time not matching the second change time, using the change record to perform a change comparison on the first data in the target database includes: Acquire a data addition set, a data deletion set, and a data modification set involving the first data in the historical engineering change, and determine the change record with the data addition set, the data deletion set, and the data modification set; In response to the mismatch between the first change time and the second change time, the data addition set, the data deletion set and the data modification set are used to perform a change comparison on the first data in the target database respectively.

5. The data synchronization method according to claim 4, It is characterized in that Also includes: Obtaining the added set index number of the data added set, obtaining the deleted set index number of the data deleted set, and obtaining the modified set index number of the data modified set; In response to the first change time not matching the second change time, using the data addition set, the data deletion set, and the data modification set to respectively perform a change comparison on the first data in the target database, including: Using the increase set index number, searching for the first content of the first data in the target database corresponding to the increase set index number, and performing a change comparison between the first content and the data increase set in the source database to obtain a first comparison result; Using the deletion set index number, searching for the second content of the first data in the target database corresponding to the deletion set index number, and performing a change comparison between the second content and the data deletion set in the source database to obtain a second comparison result; The modification set index number is used to retrieve the third content of the first data in the target database corresponding to the modification set index number, and the third content is compared with the data modification set in the source database to obtain a third comparison result.

6. The data synchronization method according to claim 5, It is characterized in that The step of changing the target database according to the change record that does not match the change comparison includes: In the first comparison result, when the first content is inconsistent with the data addition set in the source database, the data addition set in the source database is added to the first data in the target database; In the second comparison result, when the second content is inconsistent with the data deletion set in the source database, deleting the content corresponding to the deletion set index number in the target database; In the third comparison result, when the third content is inconsistent with the data modification set in the source database, the data modification set in the source database is modified to the target database.

7. The data synchronization method according to claim 1, It is characterized in that Also includes: In response to the first change time and the second change time matching, obtaining a first data form corresponding to the first data at the current time in the source database; Search the source database to see whether the first data exists and is waiting to be changed; When there is a pending change, the change content in the pending change is extracted, and the change content is compared with the content of the first data form, and the change content is changed on the first data form according to the comparison result.

8. The data synchronization method according to claim 7, It is characterized in that The changes include adding content, deleting content and modifying content; When there is a pending change, extracting the change content in the pending change, comparing the change content with the content of the first data form, and performing a change on the first data form according to the comparison result, including: Comparing the added content with the content of the first data form, and when the content of the first data form does not match the added content, adding the added content to the first data form of the source database; Comparing the deleted content with the content of the first data form, and deleting the deleted content in the first data form of the source database using the deleted content when the content of the first data form matches the deleted content; Comparing the modified content with the content of the first data form, and when the content of the first data form matches the modified content, modifying the first data form of the source database using the modified content; And synchronize the changes of executing the changed content to the target database.

9. An electronic device, It is characterized in that The electronic device includes a memory and a processor coupled to the memory, the memory stores at least one computer program, and when the at least one computer program is loaded and executed by the processor, it is used to implement the data synchronization method as described in any one of claims 1-8.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium has at least one program, and when the at least one program is loaded and executed by the processor, it is used to implement the data synchronization method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Data consistency detection method and device, storage medium, and electronic device

    CN109033186A

  • Database synchronization method and device, storage medium and computer equipment

    CN112905706A

  • Data synchronization method and device, electronic equipment and computer readable storage medium

    CN116628089A