最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

denormalization - How to ensure data consistency for denormalized data in NoSQL? - Stack Overflow

programmeradmin1浏览0评论

I'm working on an event planning app using a NoSQL database that follows a denormalization strategy to avoid expensive joins. However, I'm facing a potential issue when updating denormalized data.

Scenario

I have two functions that interact with the database:

  • updateVenue(venueId, newName, newLocation) Updates the venue name and location. Finds all invitations referencing this venue and updates them with the new venue details.
  • inviteGuest(guestName, venueId) Creates an invitation document containing the venue's name and location at the time of creation.

updateVenue starts execution and retrieves all invitations referencing the venue. Before updateVenue finishes updating invitations, inviteGuest is called. Since inviteGuest reads the venue before updateVenue commits, the newly created invitation contains outdated venue data.

发布评论

评论列表(0)

  1. 暂无评论