-1

Assuming I have an application (written in Java) that will need to send data from server to the client in JSON format, should I use an SQL database or NoSQL?

On the one hand, using NoSQL saves me hassle when updating records in the DB (just send the JSON string) and if I update a table (aka collection), I won't need to change the format of what I'm sending.. On the other hand, if I need to extract data/statistics from the DB, it becomes more complicated- and this is also a necessity of mine.

I'm currently testing out MongoDB vs MS SQL 2012, and I'm not sure which would work better.

I expect to have 5-10 collection with up to 10,000 entries in each.

Community
  • 1
  • 1
Etai
  • 1,483
  • 1
  • 11
  • 15

3 Answers3

2

I don't think anyone can answer this objectively. It requires objective measures of the relative importance to your application of the things MongoDB is good and bad at doing. Right now, the best we can say is

"we are not sure either ...".

(And if anyone is "sure" they are being non-objective.)

So my advice would be:

  • Don't be adventurous with your DB technology choices on a project where the cost of failure or deadline slippage is too high.

  • Favour the DB technologies that you are already familiar / confident with. Unfamiliar technologies have extra costs.

  • Weigh up the alternatives in a methodical fashion. Write yourself a document that lists the pros and cons of each alternative in the context of your project.

  • Trust your own judgement ...

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

MongoDB is not a key/value store, it’s quite a bit more. It’s definitely not a RDBMS either. I haven’t used MongoDB in production, but I have used it a little building a test app and it is a very cool piece of kit. It seems to be very performant and either has, or will have soon, fault tolerance and auto-sharding (aka it will scale). I think Mongo might be the closest thing to a RDBMS replacement that I’ve seen so far. It won’t work for all data sets and access patterns, but it’s built for your typical CRUD stuff. Storing what is essentially a huge hash, and being able to select on any of those keys, is what most people use a relational database for. If your DB is 3NF and you don’t do any joins (you’re just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app), MongoDB would probably kick ass for you. The real thing to point out is that if you are being held back from making something super awesome because you can’t choose a database, you are doing it wrong. If you know mysql, just use it. Optimize when you actually need to. Use it like a k/v store, use it like a rdbms, but for god sake, build your killer app! None of this will matter to most apps. Facebook still uses MySQL, a lot. Wikipedia uses MySQL, a lot. FriendFeed uses MySQL, a lot. NoSQL is a great tool, but it’s certainly not going to be your competitive edge, it’s not going to make your app hot, and most of all, your users won’t give a **** about any of this.

What am I going to build my next app on? Probably Postgres. Will I use NoSQL? Maybe. I might also use Hadoop and Hive. I might keep everything in flat files. Maybe I’ll start hacking on Maglev. I’ll use whatever is best for the job. If I need reporting, I won’t be using any NoSQL. If I need caching, I’ll probably use Tokyo Tyrant. If I need ACIDity, I won’t use NoSQL. If I need a ton of counters, I’ll use Redis. If I need transactions, I’ll use Postgres. If I have a ton of a single type of documents, I’ll probably use Mongo. If I need to write 1 billion objects a day, I’d probably use Voldemort. If I need full text search, I’d probably use Solr. If I need full text search of volatile data, I’d probably use Sphinx.

old but still true... Source

Boris the Spider
  • 59,842
  • 6
  • 106
  • 166
knowbody
  • 8,106
  • 6
  • 45
  • 70
  • I'm sorry for a swear word ;p – knowbody Apr 01 '13 at 00:38
  • I agree with your post, and I chose it as a best answer NOT because it answers my question (it doesn't address it at all), but because it will probably be the correct answer for most people who come across this question. I'm not looking for a motivational speech about building my app. It's on the way. I'm looking for real advice about which DB would be advantageous to us when dealing with JSON and still needing certain reporting capabilities. – Etai Apr 01 '13 at 07:37
  • @Etai - I take it you are taking a dig at my answer. Fair enough. But the reason nobody gave you advice is because nobody CAN give you *objective* advice. (Actually, not quite true. If you spent a few hours with an expert, presenting the complete picture of your project, he/she could probably give you some objective advice. But that will cost you money, friend.) Actually, I like this Answer too ... because of that way that it points out that there are no simple answers. – Stephen C Apr 01 '13 at 12:35
  • @StephenC totally agree with you, is like asking which car is the best not knowing what u need that car for. But as I said I found this article interesting – knowbody Apr 01 '13 at 13:06
  • @StephenC I actually voted up your answer, but I think most people who see this question would actually find knowbody's answer more relevant. Regarding the objective advice- that's really what I need. I'm not asking which car is the best... I'm asking "Which car would suit a really tall person between the two presented cars" I'm sure that there are advantages to both, but (from my understanding) JSON can be problematic with an SQL server. So I would either need to store the data as non-JSON, which would require more maintenance and work on the serverside, or I could just use a noSQL db. – Etai Apr 02 '13 at 10:09
  • FYI, I ended up going with Mongo. I figure it wouldn't hurt to learn something new... I should know by the end of the week if this will suit my reporting needs properly, it's all set up - I just need to populate the database and simulate a few scenarios. – Etai Apr 02 '13 at 10:10
1

I would suggest taking a look at this post: Storing Data in MySQL as JSON

It might give a look at what would work best for your project, besides that I personally use MySQL for just about anything I do with databases because I know MySQL, however this is NOT always the best way to do it.

Hope this helped! And good luck with your program!

Community
  • 1
  • 1
Steve Byrne
  • 1,320
  • 1
  • 16
  • 29