I am interested in migrating from a relational database to MongoDB for better performance. I would save redundant, denormalized data in several places, and I wonder if it is possible to automatically maintain data integrity WITHOUT application code.
For example, if I have a user document ...
User: { _id: "...", userName: "johndoe", displayName: "John Doe", TotalTasks: 3 }
And then the task document ...
Task: { _id "...", title: "Finish Reports", userID: "...", userName: "johndoe", userDiplayName: "John Doe" }
How can I automatically ensure that username and displayName remain unchanged in the relevant documents? How can I guarantee that TotalTasks will be updated when new tasks are added or removed for this user?
source
share