DEV Community

Discussion on: PostgreSQL vs MongoDB

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited
  • Free tiet with hosting for MongoDB is generous with Atlas. PostGRES? You have to host yourself. There is Heroku PostGRES free, but it is much more limited (in size) than Atlas.
  • MongoDB joins can be damn slow
  • MongoDB can be much easier to write programmatically, due to JSON-like syntax
  • Transaction is something new in MongoDB (recently added); and there is no save point.
  • SQL is better for constraints, honestly.
  • SQL needs an ORM, if you have JSON field. Not the case for NoSQL.
  • Raw SQL needs more learning curve, when without ORM/ODM, like JDBC alone. MongoDB is still quite easy even without ODM.
  • Foreign key hooks are still problematic.

If you are corporate, SQL is indeed a more solid solution, but not sure about dev experience.

Collapse
 
brpaz profile image
Bruno Paz • Edited

Raw SQL needs more learning curve,

I have seen this feeling a lot when talking about NoSQL vs Relational, that SQL is hard.

I don't quite understand why.

Of course, a bunch of denormalized JSON data will always be easier, but I don't think basic SQL can be that hard for beginners.

When you start doing nested subqueries, JOINS across many tables or even aggregations I can understand. Even someone with experience can sometimes get confused, but for most applications, you won´t need that complexity.

Even the language itself is more or less natural "Select this fields from this table",

It´s like start doing aggregates and other more advanced stuff in Mongo. The complexity increases.

Collapse
 
bravemaster619 profile image
bravemaster619

I more recently know that there is NoSQL injection as well

Example please?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

severalnines.com/database-blog/sec...

BTW, there is also GraphQL injection, both for SQL and NoSQL e.g. petecorey.com/blog/2017/06/12/grap...

Collapse
 
glennmen profile image
Glenn Carremans • Edited

SQL needs an ORM, if you have JSON field. Not the case for NoSQL.

PostgreSQL and MySQL both support JSON fields with operators.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

I know, but not sure about drivers' output, for example Node.js's pg.

Also, not probably not used much, is MongoDB 's capacity to cleaning data in JSON. It is harder in SQLite' s JSON1.

From what I have seen, PostGRES has different JSON querying syntax, but haven't tried yet.

Thread Thread
 
rhymes profile image
rhymes

From what I have seen, PostGRES has different JSON querying syntax, but haven't tried yet.

True, but PostgreSQL 12 added the standard SQL/JSON Path language.

So that can be portable as well :-)

My favorite place to check the status of things is Modern SQL