DEV Community

[Comment from a deleted post]
Collapse
 
nestedsoftware profile image
Nested Software • Edited

This is a difficult question to answer in a simple or general way.

One area where nosql dbs can offer an advantage is in how fast you can develop an initial prototype of an application. With a nosql db, you can just save your objects pretty much directly using json. There is no need to define any kind of schema ahead of time. Of course this means that capturing relationships, such a referential integrity, can be more of a challenge.

Another area is performance. Relational databases offer so-called acid guarantees around transactions. However, maintaining these properties comes at a cost. If you don't need to worry about such things for your application, or a part of it, it may be worth considering a nosql database. Nosql databases tend to transactional semantics with fewer guarantees than traditional relational databases.

Related to the above point, nosql databases are often used in a distributed context. For example, let's say a social network is using a nosql database. For performance, separate copies of the database are deployed to different servers around the world. You connect and post something to your profile, and it gets saved to the database you're using - let's call it DB A. Your friend, who lives on the other side of the world, logs in as well, but they connect to DB B. Your friend may not see your update right away, but eventually they will see it. This is called "eventual consistency", whereby there is not a guarantee about the timing of propagating data from one database to another. In the case of a social network, this is not a big problem (in practice your friend will see your post pretty soon after you've submitted it). However, when transferring money, it is a very real problem. If you're transferring money to your friend, the withdrawal of funds from your account and the deposit to your friend's account must happen as part of a (distributed) transaction.

I would say these are generally characteristics that separate relational from nosql databases. However, the truth is more complicated, as both kinds of databases may offer some of these features to a certain extent. You would have to look at each specific technology carefully to determine the difference.