NoSQL supports unstructured data, as simple as that.
The same can be achieved by storing json strings in Postgres. Postgres gives you strict rules and foreign keys and holds everything tight unlike Mongo which basically lets you do whatever you want to do - this is a boon sometimes, but it can also be a giant pain in the back side as well occasionally. So, why not use Postgres and enforce some strictness on your DB?
Do let know me why you picked MongoDB over Postgres (Or NOSQL over SQL)
I recently audited top 25000 sites for security & seo. This answer is based on what I learned auditing those sites.
Though HTML is a structured, within html as such there is so much of unstructured data. I couldn't create a schema to store data extracted from these html, especially when you have to account for erroneous data out there in the wild.
Simple example: there are many sites that don't close the tags. What if you want to capture them and analyze for types of errors?
So to capture such data, use nosql.
But when I wanted to analyze the data, I couldn't use nosql. I had to depend on sql (may be because I only know sql queries). There is no empirical data to prove, but I believe sql dbs are faster for querying on thousands of rows of data (may be because they are declarative).
So experiential hypothesis: use nosql dbs for schemaless data; use sql dbs for analysis.
When performance matters, it's best to use the right tool.
If you require many joins and relationships across your schema, skip MongoDB despite your preference for a MEAN/MERN stack. This is what MongoDB says on their site:
NoSQL databases are designed to handle unstructured data (e.g., texts, social media posts, video, email) which makes up much of the data that exists today.
Multiple joins add up in MongoDB. You can read more about my opinion.
Generally most of the social networking web sites prefer NOSQL (facebook,twitter,hashnode). But almost all banking system use SQL. Paytm.com use sql and they process millions of order in single day with sql.
There is a place for both (NoSQL and SQL). In most of my apps, I run a MongoDB and a PostgreSQL in parallel.
Simply chose the right tool for the right job.
In my opinion, it is a bad practice to save JSON in Postgres. You loose a lot of querying and composition options.
Depends on hat you need.
The main important difference is that SQL Consistency is "one data-blob" on one machine that doesn't shard. That's why they guys started the #nosql movement with a twitter hashtag. google and other companies moved away from 1 big data storage to a lot of small machines so the problem was:
A SQL transaction is over when the hardisk tells the machine "everything is persisted now" this means all data need to be on the same "machine". So if another machine needs the data it always has to wait for it. With NoSQL the data can be distributed on different machines because they have different transaction models.
Besides that I always think about how I need the data stored and how I have the least transformations on it. Or what Vector PACELC I do need.
Do I need consistency over availability ? And so on :)
Juha Lindstedt
Creator of RE:DOM and Liike, web architect
I've used MongoDB in all my projects since 2011 and it's been great! I never learned SQL because I found it confusing and error-prone (a lot of escaping etc needed to be done at least with PHP+MySQL). MongoDB + node.js works together like magic and I like the fact that I can do queries with JavaScript and not some weird string-based query hocus pocus language.
I haven't yet found a single thing couldn't be done with MongoDB. Complex tree structures work great, relations between collections no problem, etc.
I can't compare to PostgreSQL since I haven't used that, but what I can say is that MongoDB work great even in large projects. With every version it has gained new features and better performance. It's different alright, but for me that's a good thing.