by programminggeek · 15y ago · 0 comments
Relational databases were designed around the idea of minimizing storage footprint, and we have nearly infinite storage capacity relative to many databases, so many devs don't care about only having one copy of a piece of data in the DB.
Also, SQL is great as a data retrieval language, but it is awful for inputting data. Yes, it works, but writing data to MongoDB in general has felt more natural than generating SQL to shotgun in data.
You could argue that ORM's solve a lot of the uglyness of inputting data into a DB and I agree with you, but you still have to deal with table migrations and being able to just add a field in your code and not have to go hold the database's hand or write a migration to make it work is incredibly convenient.
In the end, MongoDB solves a lot of convenience issues for programs that don't need relational data or programmers who don't want to use an ORM, create SQL strings, or write migrations to get their database to store their data.
It's not for everybody, but if it fits your needs, it solves some problems much more conveniently than MySQL.
However, I disagree with your other statements:
(1) we do not have infinite storage. Most data stores keep everything in RAM, and that is pretty limited.
(2) It's really easy to input data into SQL. There are in fact a bunch of methods to do so (almost all still rely on SQL).
(3) (more of a comment, than disagreement) ORM's don't solve much. They just remove the need for engineering a data access API and trade it for performance and cleanliness of code.
One of my current projects is modelling a rather complex set of intertwined business processes. Part of the problem is just getting the client to explain their existing processes completely. Another part of the problem is that the processes are always changing. As soon as I think I finally have all the data models figured out, there's one more tweak. I am not great at data modelling or SQL, but tweaking a dozen 50 line joins on a daily basis is not happy fun time for anyone. At some point the specced data model, the model as implemented, and the conceptual model that's in my head get out of sync in some mysterious way, the plot is lost and it all turns to shit. On top of this I'm also trying to manage an object model that sorta maybe corresponds to the data model. In cases where the spec changes frequently, the higher cognitive load of maintaining a decent relational model is simply not worth it.
Well, foreign keys are not just a way to minimize storage: it speeds up future updates. If you duplicate your data everywhere for faster read access, your write cost just increased.