There are two client applications that can work locally and synchronize their database with the server with the Internet. The problem is that if you synchronize the device with the north, then the information of this device is considered relevant. Suppose that element 121 was deleted, then it is deleted on the server, and if you synchronize with the second client, then 121 is considered as new, which is not true, since it is simply deleted. How to make so that the data was deleted and added correctly as in Google calendars, for example. Do you really have to keep the entire change history on the server all the time?

  • Describe more accessible, the couple does not understand anything. The first one was synchronized and deleted, then the second one was synchronized, and how will it even get 121 elements if it is already deleted? And what's the change history? - Manitikyl
  • one
    121 elements removed, but on another client it is. How to distinguish this element from the new. Suddenly this is a new element that the client has created, although in fact this element needs to be removed on all clients and not added to the north. The only solution is to keep the deletion history on the server where it will be written that 121 needs to be deleted. - Pasha
  • So it turns out that this story needs to be kept constantly, because there may be customers who have not been synchronized for a long time and there is a lot of excess garbage on them. - Pasha
  • In fact, what is synchronization: if the data is relevant, we do nothing; if on the contrary, we download data from the server. To check the relevance of the data, you can even use a regular integer. Device A is synchronized with the server (the number of synchronization is 0). If device A makes changes to the database, then this number is increased by 1. Now device B, device B has an old number in memory, since in any case this number will not be equal to number 1, then the data is synchronized. On the fingers, but understandable. - Manitikyl
  • each element must have a unique ID, so who distinguishes them where and how. - Manitikyl

1 answer 1

enter image description here

So far, only this, but the removal history has to be stored on the server permanently.

  • And what is the idea with the dates did not like? In my date, the change and the creation date solve all the problems and no logs are needed - Mike
  • Only this does not solve the problem of removal - Pasha
  • one
    But, as I said in the comments questionable, we must store the last synchronization date for each client separately (on the client or on the server, in relation to the client). And we are comparing with her. - Mike
  • one
    Well, in the question you did not say a word that you can not identify him. From where I could assume that it is impossible to identify it ... Personally, I would, even if there is no synchronization, would prefer to know more about the customers and make some kind of identification. But if it is absolutely impossible, then it means to keep the synchronization date on the client and report it to the server upon connection. Although it is certainly not safe, the client can impose any behavior on the server. Although an unidentified client can tell the server at all that I have seen all the records and deleted them all from me, and clear your database to you - Mike
  • one
    maybe a device. And for reliability, I would give the client some information that he would have stored in his database. In the end, we are more interested in the state of its database, if for some reason the iron has changed, and the database has been locally copied, then we will be interested in its condition. It seems like cookies in http - Mike