users:
{
"id": "AABC",
"name": "Donna Smith"
}
photos:
{
"id": "FAD4",
"description": "cute dog",
"user_id": "AABC", // This is the relationship
"user_name": "Donna Smith" // This is the denormalized value from the "users" collection
}
photos and users . There is a one-to-many relationship between users and photos.
如何保证 consistency with data in the photos 当 user “AABC” changes name from “Donna Smith” to “Donna Chang”?
可行方案1. async tasks to update photos(user_name)
this will be only eventually consistency
- 请问还有其他更好的方法吗?
- 如何保证应用层开发的时候更新 user “AABC” changes name from “Donna Smith” to “Donna Chang”? 不会忘记更新photos(user_name), 因为这里面没有强约束。比如如果还有一个videos或者feeds table如果都包含 use_id, user_name. 感觉如果业务不熟很容易忘记更新全部 photos, videos, feeds的 user_name, 从而造成数据的不一致
- 如何保证跨组的时候不会造成数据并不一致. 比如A组做user service, B组做video service (user_id, user_name), C组做photo service (user_id, user_name). 那现在如果A组的服务给一些users改名, 如何通知B, C 组也update user_name. 极端情况下, A根本就不知道B, 和 C做了denormalisation (user_id, user_name 加到 video 或者 photo db里). 请问跨组情况如何解决 数据一致性问题
谢谢