codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

Follow publication

Data Synchronization Primer

Adolfo Marinucci
codeburst
Published in
9 min readAug 7, 2018

--

Posts
+----+-------+---------+-------+
| Id | Title | Content | Claps |
+----+-------+---------+-------+
Posts-Changes
+---------+----+----+
| Version | Id | Op |
+---------+----+----+
Synchronizations
+----------------+
| Server Version |
+----------------+
| 0 |
+----------------+
Posts                                                       local-db
+----------+----------+-----------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------+-------+
| 3ea52d6c | My Title | My amazing post | 0 |
+----------+----------+-----------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
+---------+----------+----+
Synchronizations
+----------------+
| Server Version |
+----------------+
| 0 |
+----------------+
{
"Server-Version": 0,
"Changes": [
{
"Operation" : "I",
"Id" : "3ea52d6c",
"Title" : "My Title",
"Content" : "My amazing post",
"Claps" : 0
}]
}
Posts                                                     central-db
+----------+----------+-----------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------+-------+
| 3ea52d6c | My Title | My amazing post | 0 |
+----------+----------+-----------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
+---------+----------+----+
{
"Server-Version": 1
}
Synchronizations                                            local-db
+----------------+
| Server Version |
+----------------+
| 1 |
+----------------+
Posts                                                       local-db
+----------+----------+-----------------------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------------------+-------+
| 3ea52d6c | My Title | My amazing post with images | 0 |
+----------+----------+-----------------------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
| 2 | 3ea52d6c | U |
+---------+----------+----+
Posts central-db
+----------+----------+-----------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------+-------+
| 3ea52d6c | My Title | My amazing post | 2 |
+----------+----------+-----------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
| 2 | 3ea52d6c | U |->first clap
| 3 | 3ea52d6c | U |->second clap
+---------+----------+----+
{
"Server-Version": 1,
"Changes": [
{
"Operation" : "U",
"Id" : "3ea52d6c",
"Title" : "My Title",
"Content" : "My amazing post with images",
"Claps" : 0
}]
}
Posts left join Posts-Changes                            central-db
+----------+-------+---------+-------+---------+----+
| Id | Title | Content | Claps | Version | Op |
+----------+-------+---------+-------+---------+----+
| 3ea52d6c | ... | ... | 2 | 3 | U |
+----------+-------+---------+-------+---------+----+
Posts                                                     central-db
+----------+----------+-----------------------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------------------+-------+
| 3ea52d6c | My Title | My amazing post with images | 2 |
+----------+----------+-----------------------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
| 2 | 3ea52d6c | U |->first clap
| 3 | 3ea52d6c | U |->second clap
| 4 | 3ea52d6c | U |->content change
+---------+----------+----+
{
"Server-Version": 4,
"Changes": [
{
"Operation" : "U",
"Id" : "3ea52d6c",
"Title" : "My Title",
"Content" : "My amazing post with images",
"Claps" : 2
}]
}
Posts                                                       local-db
+----------+----------+-----------------------------+-------+
| Id | Title | Content | Claps |
+----------+----------+-----------------------------+-------+
| 3ea52d6c | My Title | My amazing post with images | 2 |
+----------+----------+-----------------------------+-------+
Posts-Changes
+---------+----------+----+
| Version | Id | Op |
+---------+----------+----+
| 1 | 3ea52d6c | I |
| 2 | 3ea52d6c | U |
| 3 | 3ea52d6c | U |
+---------+----------+----+
Synchronizations
+----------------+
| Server Version |
+----------------+
| 4 |
+----------------+
Install-Package CoreSync -Version 0.1.12-beta
Install-Package CoreSync.Sqlite -Version 0.1.12-beta
Install-Package CoreSync.SqlServer -Version 0.1.12-beta

--

--

Published in codeburst

Bursts of code to power through your day. Web Development articles, tutorials, and news.

No responses yet