Eye brows may be raised when we say MongoDB doesn’t support transactions and constraints. First let us look at why we need transactions and constraints in relational databases.
Let us think about a simple blog system in relational databases.
So in relational, one transaction need to be saved in three tables. So there can be a scenario where post will get updated and tags will not be updated. To avoid this, you can run all the statements in a transaction.
Also, there can be another scenario where user can insert into tags without inserting into posts table. So the constraints are used to avoid such situations.
How are we saving this data in MongoDB.
So in MongoDB, tags and comments are embedded to the posts documents so that above scenarios will not exist.