Nevergarden
Posted on April 23, 2021
This Monday on an interview I was asked if I was supposed to start a project how do I know whether I use SQL or NoSQL?
And to tell the truth I was confused and puzzled that I really never thought of when to use them?
I forgot about that question until now and then I searched for when to use them the first thing was the actual implementation of them.
Structure
SQL is structured while NoSQL can accept unstructured data.
SQL accepts gives you a form and asks you to fill it exactly as is.
But when talking NoSQL you can provide any data to any document. But then you have to check this information when you retrieve that document.
Transaction
SQL is transactional while NoSQL provides a document-level-based transaction but not what we look for.
Think you are programming some wallets and Jack transfers 100 dollars to Jills wallet.
You write a transaction in SQL like:
BEGIN TRANSACTION
UPDATE Jack.Money -= 100;
UPDATE Jill.Money += 100;
COMMIT
This way both of them should happen so if the first command works and the second one fails then Jack's money doesn't go to waste.
But with NoSQL, we have to check their documents and then request again. (I might be wrong about this)
Also, this answer explained how NoSQL databases have lighter transactions.
Generally speaking, NoSQL solutions have lighter weight transactional semantics than relational databases, but still have facilities for atomic operations at some level.
Generally, the ones which do master-master replication provide less in the way of consistency, and more availability. So one should choose the right tool for the right problem.
…
Posted on April 23, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 26, 2024
November 11, 2024
November 14, 2024