Criteria for data synchronization

0

Good morning, I wanted tips for data synchronization criteria, let's go to the scenario.

Next I have a system with an administrative where it registers products, clients, users, releases permissions, product units, product stock among other n data.

I have the POS (Point of Sale) it needs to work without a network but then the thought I had initially.

Synchronize all data to the pdv from time to time ..

But for there and if I have 300mil products, will I synchronize all of them every 5 seconds? ever ..

so I thought about checking for the last change given (changed attributeEm) every time I save a product or any other data that is synchronized with the pdv I set the current date and time in the changed attribute It is based on the last Synchronization

lastSynchronization < changedEm ----- synced everything

save date from last Sync

and bingo! has it improved?

but ... and if the user returns the pc date and save a product .. hahaha screwed up my life = /

ai and where do I want to know what criteria to use to synchronize data ..

Here I use sql server 2008

    
asked by anonymous 21.03.2016 / 14:25

2 answers

0

General algorithm

Have a versaoLocal field and a versaoRemota field. Test if they are different. If different, needs updating, if not, good are the same, nothing to do.

The specific algorithm is:

  • In a given location you only update the versaoLocal field.
  • Raises all records with versaoLocal ! = versaoRemota .
  • Each one runs the update process
  • Each using data in memory , makes versaoLocal = versaoRemota (if download), or versaoRemota = versaoLocal , if uploaded.
  • With timestamps

    Testing for difference solves the issue of wrong clocks, timezones, daylight savings time ...

    It still runs the risk of matching a local timestamp equal to a remote timestamp. Low risk, but it exists. If you use timestamps, put the maximum of decimals of milliseconds available.

    rowversion, UUID, or triggers

    Instead of relying on date / time, use another versioning source. Some banks provide rowversion fields, which guarantee for that bank instance will always have a new number, with no reps, every UPDATE. You have the SQL Server 2008 .

    As another alternative, triggers in the database, which in any UPDATE increment the number versaoLocal of that record.

    Again, just test by difference to know when to upgrade.

        
    21.03.2016 / 16:27
    0

    Well, next your idea is good but we solved it differently here in the company,

    we did so, we will have a table (pendentes_sync) (int reference, int terminaloffline, int type, synchronized)

    reference and the ID of the object I want to synchronize terimaloffline is the terminaloffile ID (explain below) type Synchronized within the system it will be an enum .. that says the type of data being synchronized, example if it is 1 .. is a Product, if 3 is a user, if 7 is product_unit and so goes ..

    Offline Terminal What is it? Good offline terminal (I'll give a pdv example)

    You are in the supermarket and you are starting to install the system you install the administrative and the pdvs, to start a pdv you must have an Offline Terminal .. if you do not have the pdv simply will not leave the terminal selection screen offline ..

    Offline terminal registration .. could have an ECF already registered and linked to the pdv if you know the door that will be put here .. if you do not know ok from nowhere does not select in the pdv .. a description for the offline terminal, synchronization time, is an attribute for tying the pdv to a particular offline terminal,

    When registering the offline terminal, you simply select it in pdv and bingo! a preconfiguration is ready suppose you made the registration and erred the ECF port the pdv .. will not connect but rather show an option to put the correct ecf port .. you put (the synchronizer will send the port to the register on the server) p>

    basically this is the offline terminal ..

    let's part of the synchronization

    pending_sync the table I gave you above ...

    When I register a product I will have to insert the reference (product id), idterminalOffline (if you have two terminals you will need to have two inserts one for each ..), type Synchronized (an indicator that you are synchronizing a product)

    the same process to change the product ..

    Well, what happens .. if you have two terminals .. you will have two inserts one for each terminal

    When the (terminal) pdv synchronizes it will be based on this table. get her data .. will see that there is pending product to synchronize .. takes its id from it looks for it and updates / inserts the product in the pdv .. and deletes the record of the pending_sync table that referred to this update ..

    And basically that's what we think

    If you have any idea where we can improve and welcome =)

        
    22.03.2016 / 01:27