Earlier quoted context omitted.
Why not just use a SQL db that handles json and stick everything in a couple columns? Changing databases is a lot of work, and as far as I can tell, mongo isn’t really providing much value over SQL dbs that already support schemaless json columns.
Because you still have to write a layer between your web app and the database at the prototyping stage? I can't just make calls from Html + JS to Postgres. But I can with MongoDB
Was MongoDB Ever the Right Choice?
51–60 of 224 posts
Re: Was MongoDB Ever the Right Choice?
#52> Loss of transactions
MongoDB 4.0 supports ACID transactions: https://www.mongodb.com/transactions
> Loss of relational integrity (foreign keys)
> Having a database enforce these relationships can offload a lot of work from your application, and therefore from your engineers.
I've never seen anyone use MongoDB without also using something like Mongoose where you get all this for free. Zero work for your engineers. https://mongoosejs.com/
> Lack of ability to enforce data structure
Again, Mongoose. The work doesn't fall on your engineers, it falls on an awesome, heavily-used, heavily-tested library.
> Custom query language
Can you give an example of something that you realistically would want to do in SQL that you can't with a JSON query?
> Loss of tooling ecosystem
This might be the only valid caveat in the entire article.
Re: Was MongoDB Ever the Right Choice?
#53My anecdote: several years back I had a test lab for measuring the performance and scalability characteristics of various geospatial databases. We added MongoDB to the mix a couple years after they released geospatial support. We always verified basic correctness with a new database by inserting several billion geometries as fast as the database would accept them, reading the entire data set back out, and comparing i…
Re: Was MongoDB Ever the Right Choice?
#54Off course it was, prototyping speed on mongodb was (and probably still is) always excellent. Some features that don't scale are very nice to have when you don't have scaling issues. For example, if you add tags to your documents and you want to query on those tags (find all documents containing tag A and B), it's nice that's just a builtin. I haven't found a single datastore that is as developer friendly that suppor…
The other answers have confirmed that Postgres will do this with array fields, and it's good advice to follow. It's also in my view much easier to read than MongoDB's query language is! CREATE TABLE documents (name text, tags text[]); INSERT INTO documents VALUES ('Doc1', '{tag1, tag2}'); INSERT INTO documents VALUES ('Doc2', '{tag2, tag3}'); INSERT INTO documents VALUES ('Doc3', '{tag2, tag3, tag4}'); SELECT * FROM…
As I already use MySQL in many projects, I do much the same thing with MySQL's json support.
I believe json is now supported by Sqlite too.
Basically, if you already have an up-to-date relational database, then the chances are you can already use it as a sane document store.
Just saying, so nobody reading the threads thinks they have to go grab some new database if they are already using one!
Re: Was MongoDB Ever the Right Choice?
#55Re: Was MongoDB Ever the Right Choice?
#56Earlier quoted context omitted.
> Why not just use a SQL db that handles json and stick everything in a couple columns? Honest question: what's wrong with just defining a domain model, adopting an ORM and a serialization framework, and simply go with a conventional RDBMS? Afaik all reference web application frameworks handle this right out of the box.
Nothing on paper, if you get the schema more or less correctly the first time. The problem is when you need to do a schema change that affects terabytes of data down the road.
With an enforced schema you will at least know that all of the existing data matches the schema. Without it you have to hope that you had zero bugs while collecting the terabytes of data.
Re: Was MongoDB Ever the Right Choice?
#57I work at MongoDB, so I do want to mention that MongoDB has changed a lot over the past few years. MongoDB now has multi-document ACID transactions. Also, schema validation means you can enforce a strict data structure if you want. On top of that there have been improvements in data durability and consistency (the Jepsen tests are now integrated into the MongoDB test suite).
As mentioned in the article MongoDB has matured a great deal. It's far more mature and fully-featured in 2019 than it was in 2012.
Re: Was MongoDB Ever the Right Choice?
#58Earlier quoted context omitted.
Mongo's debut was well timed to ride the JSON crazewave.
Sorry for my ignorance, but what JSON craze?
Re: Was MongoDB Ever the Right Choice?
#59I know MongoDB supports references, but it's like using a flathead driver for a Phillips head screw.
Re: Was MongoDB Ever the Right Choice?
#60These "caveats" are mostly false, or outdated. > Loss of transactions MongoDB 4.0 supports ACID transactions: https://www.mongodb.com/transactions > Loss of relational integrity (foreign keys) > Having a database enforce these relationships can offload a lot of work from your application, and therefore from your engineers. I've never seen anyone use MongoDB without also using something like Mongoose where you get all…
Custom query language - I bet he also hates ElasticSearch. But again, using C# and the first party Mongo LINQ library, you are working with LINQ - the same built in C# query language that every C# developer should be familiar with. One of the requirements I wrote when I was hiring contractors for a Mongo based project was familiarity with Entity Framework. Even though we wouldn’t be using EF, if they knew it, it would be seamless to transition over to Mongo/LINQ.
Edit:
And as a side note, creating your “application defined schema” from a pre-existing JSON document, is a simple matter of copying the JSON to: