Take the 2-minute tour ×
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It's 100% free, no registration required.

How can NoSQL databases like MongoDB be used for data analysis? What are the features in them that can make data analysis faster and powerful?

share|improve this question
2  
The major use is storing data and retrieving data. In fact, that's about the only use for a NOSQL database, or any database. Want to make your question better? –  Spacedman Jul 22 at 15:09
    
Yes, database is mainly used for storing and retrieveing data. How can they be used for data analysis? What are the tools built into NOSQL databases like mongodb which makes data analysis easy and powerful? –  jithinjustin Jul 22 at 16:56
1  
Improve your question by editing it, not adding to the comments. –  Spacedman Jul 22 at 16:57

3 Answers 3

up vote 11 down vote accepted

To be perfectly honest, most NoSQL databases are not very well suited to applications in big data. For the vast majority of all big data applications, the performance of MongoDB compared to a relational database like MySQL is significantly is poor enough to warrant staying away from something like MongoDB entirely.

With that said, there are a couple of really useful properties of NoSQL databases that certainly work in your favor when you're working with large data sets, though the chance of those benefits outweighing the generally poor performance of NoSQL compared to SQL for read-intensive operations (most similar to typical big data use cases) is low.

  • No Schema - If you're working with a lot of unstructured data, it might be hard to actually decide on and rigidly apply a schema. NoSQL databases in general are very supporting of this, and will allow you to insert schema-less documents on the fly, which is certainly not something an SQL database will support.
  • JSON - If you happen to be working with JSON-style documents instead of with CSV files, then you'll see a lot of advantage in using something like MongoDB for a database-layer. Generally the workflow savings don't outweigh the increased query-times though.
  • Ease of Use - I'm not saying that SQL databases are always hard to use, or that Cassandra is the easiest thing in the world to set up, but in general NoSQL databases are easier to set up and use than SQL databases. MongoDB is a particularly strong example of this, known for being one of the easiest database layers to use (outside of SQLite). SQL also deals with a lot of normalization and there's a large legacy of SQL best practices that just generally bogs down the development process.

Personally I might suggest you also check out graph databases such as Neo4j that show really good performance for certain types of queries if you're looking into picking out a backend for your data science applications.

share|improve this answer
    
You are right. NOSQL databases are mainly used for storing unstructured or semi-structured data like json. Can you explain some of the types of data analysis we can do with them. What are the tools built into mongodb that can used for data analysis? –  jithinjustin Jul 22 at 15:32
    
@jithinjustin there aren't data analysis tools built into mongo, or really any database. Also, json is totally structured data. You can technically do any kind of data analysis on it, using a NOSQL database is actually not related. There are tools built on top of mongo, like analytica though. –  indico Jul 22 at 17:39
    
I don't know about all that. MongoDB can perform better than MySQL. You'd have a better argument if you said PostgreSQL (which, by the way can accept JSON). Either way, I wouldn't consider some arbitrary "performance" (we don't know what the use case is) to be a reason not to use NoSQL. Also don't discount using multiple databases. Remember, MongoDB has amazing aggregation features that SQL does not have. –  Tom Jul 25 at 2:56
    
@Tom on performance, you'll find that the only task that mongo actually outperforms mysql on is inserts (moredevs.ro/mysql-vs-mongodb-performance-benchmark), which is a comparatively small part of data analysis. SQL's aggregation features are FAR more mature than Mongo's. As far as MYSQL versus Postgres, the numbers are very temporily skewed and both tend to offer similar performance. MYSQL is more common, which is why I mentioned that instead, but the two are quite similar. –  indico Jul 25 at 21:59
    
I've always seen better performance on MongoDB when things fit into memory. I take benchmarks with a gain of salt because if you Google a bit you're gonna find a bunch of benchmarks showing MongoDB as faster. It truly depends on your needs. That said, to help answer the original question - I think there's plenty of uses for NoSQL in big data science and analytics. –  Tom Jul 26 at 3:29

One benefit of the schema-free NoSQL approach is that you don't commit prematurely and you can apply the right schema at query time using an appropriate tool like Apache Drill. See this presentation for details. MySQL wouldn't be my first choice in a big data setting.

share|improve this answer

Consider, try, and perhaps even use multiple databases. It's not just a "performance" issue at play here. It's really going to come down to your requirements. How much data are you talking about? what kind of data? how fast do you need it? Are you more read heavy or write heavy?

Here's one thing you can't do in a SQL database: Calculate sentiment. http://www.slideshare.net/shift8/mongodb-machine-learning

Of course the speed in that case may not be fast enough for your needs, but it is something that's possible. With some caching of specific aggregate values, it was quite acceptable even. Why would you do this? Convenience.

Convenience really is something that you're going to be persuaded by. That's exactly why (in my opinion) NoSQL databases were created. Performance too of course, but I'm trying to discount benchmarks and focus more on other concerns.

MongoDB (and some other NoSQL) databases have some very powerful features such as built-in map/reduce. This could result in a savings both in cost and time over using something like Hadoop. Or it could provide a prototype or MVP to launch a larger business.

What about graph databases? They're "NoSQL" too. Look at databases like OrientDB. If you want to argue performance ...I don't think you're gonna show me a SQL database that's faster there =) ...and graph databases have some really amazing application based on what you need to do.

Rule of technology (and the internet) don't get too comfortable with one thing. You're gonna be limited and set yourself up for failure.

share|improve this answer
1  
I don't see anything in that link or here that proves you can't do sentiment analysis in an SQL database. the mongoDB examples benefit from Javascript in the DB, so you could use any embedded language in an SQL database. For example Postgres + R. –  Spacedman Jul 25 at 12:54
    
Would love to see where you could execute code and map/reduce in those databases. In all seriousness (especially Postgres). ...and even if you could, that still doesn't make the answer any less valid by the way. One simply just might want to use NoSQL. It does work. –  Tom Jul 25 at 14:07
1  
Postgres + C, Python, Perl, R, feed your Postgres DB into the latest machine learning algorithms. Easy: postgresql.org/docs/9.0/static/xplang.html –  Spacedman Jul 25 at 15:00
    
Nice. I'll have to try that out sometime. How about MySQL? –  Tom Jul 25 at 15:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.