MongoDB - automatically maintain data integrity

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?

+3
source share
2 answers

. - -, . , , .

+4

MongoDB - . , , , ? , .

, , , , MySQL . , :

1) doc Mongo MySQL. MySql , ( , ..), 2) , , mysql. 3) , concurrency. 4) , mysql. 5) - , . , , "". 6) mysql

, , , , user → , , .

0

Source: https://habr.com/ru/post/1787814/


All Articles