joplin-notes/joplin notion extension/Web Development/sql/extras.md
2026-11-04 00:33:23 +05:30

1 KiB

extras

  • pocketbase : for small projects
  • Conflict-Free Replicated Data Type: A conflict-free replicated data type (CRDT) is a special distributed data structure that lets multiple computers store, update, and sync copies of data independently without needing a central coordinator or locking mechanism
  • last write wins
  there is a table name tab and it contains a column name col.

now this database is in both devices and is same too. values in column 'col' of table 'tab' in both database are A.B,C which is last modified at 5pm

in device1 changes being made and now its value is X,B . this database is last updated at 6pm
in device2 changes being made and now its value is Y,C. this database is last updated at 7pm

now how to sync the changes?
in first one, A is replaced with X, C is deleted
in 2nd one, A is replaced with Y, B is deleted

so total changes are
A -> X
C -> gone
A -> Y
B -> gone

here A being updated to either X and Y is decided by time so latest one ie 7pm one win and A->Y, B and C are deleted
so finally it will be Y