News for hackers. Stuff that matters.
Re:Why You Should Never Use MongoDB by dasil003 on Monday November 11, 2013 @03:32PM (#6713796)
There is a good reason that relational databases have long been the default data store for new apps: they are fundamentally a hedge on how you query your data. A fully-normalized database is a space-efficient representation of some data model which can be queried reasonably efficiently from any angle with a bit of careful indexing.

Of course relational databases being a hedge, are not optimal for anything. For any particular data access pattern there's probably an easy way to make it faster using x or y nosql data store. However as the article points out, before you decide to go that route you better be pretty certain that you know exactly how you are going to use your data today and for all time. You also should probably have some pretty serious known scalability requirements otherwise it could be premature optimization.

Neither of these things are true for a startup, so I'd say startups should definitely stay away from Mongo unless they really know what they are doing. Being ignorant of SQL and attracted by the "flexibility" of schema-less data stores powered by javascript is definitely the wrong reason to look at Mongo.

Re:Why You Should Never Use MongoDB by nashequilibrium on Monday November 11, 2013 @04:07PM (#6714041)
I actually started to laugh as i was reading because i knew what problems they were going to run into. I was basically drawing up my schema for a mongodb app(yes you still need a schema), when i started scratching my head and started reading through the mongodb guides. I quickly realised that i should use a relational store and my problems were solved quickly with postgres.

The title of this article should be honestly changed as it does not do mongodb justice, there are a lot of uses for it but relational is not one. Regarding the TV example, this is a classic relational solution and i enjoyed this exact example in a pycon tut,SQL for Python Developers - http://www.youtube.com/watch?feature=player_embedded&v=Thd8y...

I see a lot of people thinking MVP ---> schemaless to save time -----> mongodb but you will always need a schema unless you are just dumping a list of stuff. I would like to say that another cool solution is an RDF data store, i have been using Fuseki with SPARQL.

Re:Why You Should Never Use MongoDB by jerven on Tuesday November 12, 2013 @03:17PM (#6720649)
I use SPARQL a lot although not Fuseki. I really like the flexibility it gives in the schema (flexible not less schema). As well as that one query language can be used on radically different implementations i.e. I don't need to change my datamodel or queries to try different storage models.

Although we also use BerkleyDB/je+lucene for indexing as well as a number of existing relational databases. Yet, considering the youth of the SPARQL eco system (1.1 of the standard is only out since the beginning of this year) there is some fantastic performance possible for both hard and easy queries. I think it will be a bit like Java, not pretty, but fast enough and extremely robust in the long run. With a similar marketing pitch "Query Once Store Anywhere".

I also evaluated MongoDB, and I understand the value of a document store. I just don't think that MongoDB is a good document store, imho it just a slow /dev/null.

Re:Why You Should Never Use MongoDB by camus2 on Monday November 11, 2013 @03:57PM (#6713973)
> Being ignorant of SQL and attracted by the "flexibility" of schema-less data stores powered by javascript is definitely the wrong reason to look at Mongo.

It's usually the only reason. And 10gen were good at marketing it.

Re:Why You Should Never Use MongoDB by chadcf on Monday November 11, 2013 @06:22PM (#6714806)
I used it for exactly one production app and it was a huge success. The reason I used it was because the data we needed to represent was actually a document, in this case a representation of fillable form fields in a pdf document. The basic structure was that documents had sections and sections had fields and fields had values, types, formatters, options, etc.

Initially trying to come up with a schema in SQL was somewhat painful as what I was really looking for was an object store. Switching to mongo gave me a way to do a very clean, simple solution that worked quite well for the problem at hand (representing pdf forms). That said, we also played it very safe and used mongo for only the document portion, with every other part of the system being in an sql database. But for the doucuments mongo worked really well as a basic object store without the complexity of something like Neo4j.

Re:Why You Should Never Use MongoDB by tensor on Monday November 11, 2013 @07:18PM (#6715039)
Of course, a better choice now would be to use PostgreSQL's new JSON support. Postgres has also had XML document types for a long time, though I'm not sure of their indexing story.

If you don't need indexing into the document, you can easily just store it as serialized bytea data. I've done this quite frequently and it works wonderfully.

Re:Why You Should Never Use MongoDB by threeseed on Monday November 11, 2013 @07:51PM (#6715160)
Sorry but PostgreSQL's JSON query syntax is insanely complicated compared to MongoDB.

And that is a big deal for a lot of developers.

Re:Why You Should Never Use MongoDB by tensor on Monday November 11, 2013 @08:07PM (#6715216)
I just took a look, and if I'm getting this right, it looks about as simple as it gets:

SELECT json_data FROM people WHERE json_data->'age' > 15

vs

db.people.find( { age: { $gt: 10 } } )

Personally, I prefer the postgres syntax. It's much clearer. I also don't buy your claims below about performance. Can you provide a real benchmark? Are you running with the safeties off meaning you lose data?

Re:Why You Should Never Use MongoDB by dbcfd on Monday November 11, 2013 @09:00PM (#6715392)
What is the syntax on finding an array value matching some key? E.g. given a user with field "favFoods":[String], how do I determine that pizza is in there?
Re:Why You Should Never Use MongoDB by jessedhillon on Monday November 11, 2013 @10:14PM (#6715627)
select ... where "pizza" in person -> favFoods
Re:Why You Should Never Use MongoDB by jessedhillon on Tuesday November 12, 2013 @03:29AM (#6716501)
Sorry I'm stupid, I was thinking Python

select ... where person -> favFood in ("pizza")

Re:Why You Should Never Use MongoDB by gfodor on Tuesday November 12, 2013 @01:59AM (#6716289)
Your ORM will give you whatever syntax is natural, eventually.
Re:Why You Should Never Use MongoDB by idProQuo on Monday November 11, 2013 @07:11PM (#6715002)
For all the talk about how "MongoDB totally has SOME use cases", I've never before heard of a use case where it would be unambiguously better to use a document store. Thanks for explaining that so well.
Re:Why You Should Never Use MongoDB by threeseed on Monday November 11, 2013 @07:50PM (#6715156)
I've used it well in the past as well.

MongoDB was 5-10x faster than PostgreSQL, Cassandra etc.

If your domain model is structured like a document then MongoDB is a pretty great fit.

Re:Why You Should Never Use MongoDB by leccine on Tuesday November 12, 2013 @04:37PM (#6721351)
Even if it is better, why Mongo? Why not Riak?
Re:Why You Should Never Use MongoDB by yayitswei on Tuesday November 12, 2013 @12:58AM (#6716122)
In my opinion, datalog (via Datomic) strikes a good balance between schema flexibility and queryability. It's my preferred way of working with data now, after using Mongo for a year (I was also initially attracted by the flexibility of schema-less data stores).
Re:Why You Should Never Use MongoDB by mattkrea on Monday November 11, 2013 @05:31PM (#6714570)
I think a lot of people (at least in the Node community) love the interfaces provided for it and specifically Mongoose which allows you to enforce a schema and thus relational data.

I'll admit that I originally got into it because I didn't really know SQL and I'm still not very talented with it but for example.. Joins in Mongoose? Say there is a comment.. this comment has an author. If that author is type ObjectId when I run a query I can do this:

model.comment.find({_id: <some id>}).populate('author').exec(e, result) { // author will be populated with that author's data instead of just the ID }

Re:Why You Should Never Use MongoDB by camus2 on Monday November 11, 2013 @09:19PM (#6715465)
I use mongodb only when i have to write an app in Node. Not because it's the better solution , but because mongoose is the only library that deals with data that is mature on npm. The rest is beta at best and drivers for RDBMS are not mature enough.
Re:Why You Should Never Use MongoDB by hoffer on Tuesday November 12, 2013 @12:52PM (#6719387)
The mysql driver on NPM is indeed mature. Been using it with out issue for a couple years now in a large app. https://npmjs.org/package/mysql
Re:Why You Should Never Use MongoDB by mattkrea on Monday November 11, 2013 @11:49PM (#6715909)
I had thought the mysql drivers were all more mature or is it that you lean more toward postgresql?
Re:Why You Should Never Use MongoDB by jacques_chester on Monday November 11, 2013 @11:41PM (#6715877)
Putting it another way:

Document stores are supposedly "more agile", but by conflating queries, the logical model and the physical structure, they are actually less agile. You've mixed the three things together and ossified around a single model of the domain. When the required view or model changes, you have to write workarounds.

Re:Why You Should Never Use MongoDB by gfodor on Tuesday November 12, 2013 @01:53AM (#6716278)
spot on. MongoDB is a step backwards in abstraction. The RDBMS geeks had this figured out in the 70s. Hence the "relational MODEL" vs "document STORE" transparent step backwards in generalization.

MongoDB is just locking you into a specific materialization of an ill-specified data structure. PostgreSQL's team hacked out JSON support in about a year or so, since they are working at a higher level of abstraction and could insert the "MongoDB model" at the proper place in their system. Now if you really need to store "documents" in your database and query lazily-defined fields you can do that for those edge cases (and lets face it, those are edge cases) and use proper relational modeling for the rest of your model.