H
H
Hosting Yaroslavl2019-11-29 15:25:40
PHP
Hosting Yaroslavl, 2019-11-29 15:25:40

How to program PHP / MYSQL so that later you can synchronize the database?

Suppose there is a simple DB
table sale: sale_id, nomenclature_id, count, price, sum... table
nomenclature: nomenclature_id, name...
was to sync?
from a simple thing that comes to mind - these are the prefixes of branches in id (1000001, 1000002 - the id of all records in branch 1 and N000001, N000002, .... in branch N), but then during synchronization, items with the same name and different ID will pop up , if both branches, for example, buy a light bulb for the first time and capitalize it each by creating an item.
What is the principle of building such programs so as not to reinvent the wheel and write your own synchronization algorithms, but to use something standard / ready-made like rsync?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Romashkan, 2019-11-29
@EvgeniiR

What and with what to synchronize?
To prevent id from overlapping on several nodes, you can use UUID.
Anything else like microtime + node ID is possible, but it is hardly necessary without some serious performance requirements

L
Lazy @BojackHorseman PHP, 2019-12-01
Tag

use natural keys rather than surrogate autoincremental ones

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question