个人网站www.pixysoft.net设计系列: 目标数据库同步的重构
Purpose
把版本控制管理与业务数据分离.提高灵活性
Use Case 1 Insert Version Question
用户A初始化新信息 LA
.数据新插入的时候,所有版本为0 LA0
用户A上传信息到网站 LA - W
.LA1, W1
用户B下载信息
LA1 W1 LB1
用户A修改信息,用户B修改信息
LA1 W1 LB1
用户A上传信息,之后B才上传
LA2 W2 LB1 此时用户B认为版本过时.错误 because B version < Server Version
Use Case 2 Insert Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1,W100-1, LB100-1
用户A新建一条信息
LA100-1,LA0
W100-1
LB100-1
用户A上传信息
此时LA100-1不上传,因为没有发生修改(mark = false)
LA100-1 LA2,
W100-1 W2,
LB1
User B download
LA100-1 LA2
W100-1 W2
LB100-1 LB1-2
Use Case 3 Insert CVC Info Question
用户A有100信息, 全部上传之后.User B download
LA100-1,W100-1
B download 100 CVC Info, and compare
用户A新建一条信息,用户A上传信息,User B download
LA100-1 LA2,
W100-1 W2,
LB1
B download 1 CVC Info, and compare (because B min Ver = 1, and just need to get ver>1 from W)
Use Case 4 Update Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A change one Info, and upload
LA99-1 LA1-2
W99-1 W1-2
LB99-1 + LB1-1
User B download
LA99-1 LA1-2
W99-1 W1-2
LB99-1 + LB1-2
Use Case 4 Update CVC Info Question
用户A有100信息, 全部上传之后.User B download
same as above
User A change one Info, and upload
此时LA99-1不上传,因为没有发生修改
same as above
User B download
LA99-1 LA1-2 / W99-1 W1-2 / LB99-1 + LB1-1
B download 1 CVC Info, and compare (because B min Ver = 1, and just need to get ver>1 from W)
Use Case 5 Adv UpdateVersion Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A update, User B update
LA99-1 LA1-1/ W99-1 W1-1 / LB99-1 + LB1-1
User B upload
LA99-1 LA1-1/ W99-1 W1-2 / LB99-1 + LB1-2
if User A download
LA99-1 LA1-2/ W99-1 W1-2 / LB99-1 + LB1-2
if User A upload
conflict
Use Case 6 Delete Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A delete 1
LA99-1 LA1-1[delete]/ W99-1 W1-1 / LB99-1 + LB1-1
User A upload
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 + LB-1
User B download
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 [none]
Use Case 7 Adv Delete Version Question
User insert 100 info, upload, delete 1 and upload it. then User B download
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 [none]
User A update 1
LA98-1 LA1-1 / W99-1 W1-2[delete] / LB99-1 [none]
User A upload
LA98-1 LA1-2 / W98-1 W1-2[delete] W'1-2 / LB99-1
User B download
LA98-1 LA1-2 / W98-1 W1-2[delete] W'1-2 / LB98-1 LB1-2
________________________________________________________________________
suppse User A update next 97, insert 10000, and upload
User A: LA1-1 LA1-2 LA97-3, LA10000 - 3
the server: W1-1 W1-2[delete] W1-2 W97-3 W"10000 -3
Then User A update last 1, upload
User A: LA1-4 LA1-2 LA97-3, LA10000 - 3
the server: W1-4 W1-2[delete] W1-2 W97-3 W"10000 -3. This time, the server can truly delete the W1-2, because the V for delete <= min V of undelete one
Suppse this time User B begin to download
User A: LA1-4 LA1-2 LA97-3, LA10000 - 3
the server: W1-4 W1-2 W97-3 W"10000 -3.
User B: LB97-3 LB1-4 LB1-2 LB1000-3
________________________________________________________________________
Use Case 8 Adv Delete Version Question 2
A insert 100
la100-0
A upload 100
la100-1
w100-1
B download
la100-1
w100-1
lb100-1
A delete 99
la1-1 la99-1[delete]
w100-1
lb100-1
A upload
la1-1
w1-1 w99-2[delete]
lb1-1 lb99-1
A insert 50
la1-1 la50-0
w1-1 w99-2[delete]
lb1-1 lb99-1
A upload,
la1-1 la50-3
w1-1 w99-2[delete] w50-3
lb1-1 lb99-1
A update(from insert 50) 1
la1-1 la49-3 la1-3
w1-1 w99-2[delete] w50-3
lb1-1 lb99-1
A upload
la1-1 la49-3 la1-4
w1-1 w99-2[delete] w49-3, w1-4
lb1-1 lb99-1
把版本控制管理与业务数据分离.提高灵活性
Use Case 1 Insert Version Question
用户A初始化新信息 LA
.数据新插入的时候,所有版本为0 LA0
用户A上传信息到网站 LA - W
.LA1, W1
用户B下载信息
LA1 W1 LB1
用户A修改信息,用户B修改信息
LA1 W1 LB1
用户A上传信息,之后B才上传
LA2 W2 LB1 此时用户B认为版本过时.错误 because B version < Server Version
Use Case 2 Insert Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1,W100-1, LB100-1
用户A新建一条信息
LA100-1,LA0
W100-1
LB100-1
用户A上传信息
此时LA100-1不上传,因为没有发生修改(mark = false)
LA100-1 LA2,
W100-1 W2,
LB1
User B download
LA100-1 LA2
W100-1 W2
LB100-1 LB1-2
Use Case 3 Insert CVC Info Question
用户A有100信息, 全部上传之后.User B download
LA100-1,W100-1
B download 100 CVC Info, and compare
用户A新建一条信息,用户A上传信息,User B download
LA100-1 LA2,
W100-1 W2,
LB1
B download 1 CVC Info, and compare (because B min Ver = 1, and just need to get ver>1 from W)
Use Case 4 Update Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A change one Info, and upload
LA99-1 LA1-2
W99-1 W1-2
LB99-1 + LB1-1
User B download
LA99-1 LA1-2
W99-1 W1-2
LB99-1 + LB1-2
Use Case 4 Update CVC Info Question
用户A有100信息, 全部上传之后.User B download
same as above
User A change one Info, and upload
此时LA99-1不上传,因为没有发生修改
same as above
User B download
LA99-1 LA1-2 / W99-1 W1-2 / LB99-1 + LB1-1
B download 1 CVC Info, and compare (because B min Ver = 1, and just need to get ver>1 from W)
Use Case 5 Adv UpdateVersion Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A update, User B update
LA99-1 LA1-1/ W99-1 W1-1 / LB99-1 + LB1-1
User B upload
LA99-1 LA1-1/ W99-1 W1-2 / LB99-1 + LB1-2
if User A download
LA99-1 LA1-2/ W99-1 W1-2 / LB99-1 + LB1-2
if User A upload
conflict
Use Case 6 Delete Version Question
用户A有100信息, 全部上传之后.User B download
LA100-1
W100-1
LB100-1
User A delete 1
LA99-1 LA1-1[delete]/ W99-1 W1-1 / LB99-1 + LB1-1
User A upload
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 + LB-1
User B download
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 [none]
Use Case 7 Adv Delete Version Question
User insert 100 info, upload, delete 1 and upload it. then User B download
LA99-1 [none] / W99-1 W1-2[delete] / LB99-1 [none]
User A update 1
LA98-1 LA1-1 / W99-1 W1-2[delete] / LB99-1 [none]
User A upload
LA98-1 LA1-2 / W98-1 W1-2[delete] W'1-2 / LB99-1
User B download
LA98-1 LA1-2 / W98-1 W1-2[delete] W'1-2 / LB98-1 LB1-2
________________________________________________________________________
suppse User A update next 97, insert 10000, and upload
User A: LA1-1 LA1-2 LA97-3, LA10000 - 3
the server: W1-1 W1-2[delete] W1-2 W97-3 W"10000 -3
Then User A update last 1, upload
User A: LA1-4 LA1-2 LA97-3, LA10000 - 3
the server: W1-4 W1-2[delete] W1-2 W97-3 W"10000 -3. This time, the server can truly delete the W1-2, because the V for delete <= min V of undelete one
Suppse this time User B begin to download
User A: LA1-4 LA1-2 LA97-3, LA10000 - 3
the server: W1-4 W1-2 W97-3 W"10000 -3.
User B: LB97-3 LB1-4 LB1-2 LB1000-3
________________________________________________________________________
Use Case 8 Adv Delete Version Question 2
A insert 100
la100-0
A upload 100
la100-1
w100-1
B download
la100-1
w100-1
lb100-1
A delete 99
la1-1 la99-1[delete]
w100-1
lb100-1
A upload
la1-1
w1-1 w99-2[delete]
lb1-1 lb99-1
A insert 50
la1-1 la50-0
w1-1 w99-2[delete]
lb1-1 lb99-1
A upload,
la1-1 la50-3
w1-1 w99-2[delete] w50-3
lb1-1 lb99-1
A update(from insert 50) 1
la1-1 la49-3 la1-3
w1-1 w99-2[delete] w50-3
lb1-1 lb99-1
A upload
la1-1 la49-3 la1-4
w1-1 w99-2[delete] w49-3, w1-4
lb1-1 lb99-1