It is not just a database issue, but also a file synchronization issue.
Background: In a distributed system, a master station and multiple sub-stations need to synchronize the sub-station data to the master station. The sub-station data includes database records and a large number of files.
Both the master site and the sub-site have two tables A and B. The relationship between A and B is one-to-multiple.
The problem is that the distributed design was not taken into account when the system was designed, so no code was specified for the sub-station, therefore, the data ID of the sub-station is the same as that of the master station.
If the main station does not have any data from the sub-station, we can easily Insert the data from the sub-station into the main station by traversing the data exported from the sub-station,
However, if the child station edits the data, the data on the master station cannot be updated. For example, if the sub-site deletes a piece of data from Table B and the data is imported to the master site, it cannot be determined. because we do this, we traverse each piece of data from the sub-station. If the master station does not have one, we insert it.
Currently, the distributed system is not considered in our system, so many tables do not add device ID for the record.
My ideas are as follows:
Add a record ID in the master site and the slave site database, which is the unique ID and the ID of the slave site. Add a log table to the sub-site to record the addition, deletion, and update of data in each table, so that each data synchronization only needs to be exported from the log table. In this way, we can easily implement incremental export.
I don't know. Is there a problem?