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?
2$\begingroup$ 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? $\endgroup$– SpacedmanJul 22, 2014 at 15:09
$\begingroup$ 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? $\endgroup$– 10landJul 22, 2014 at 16:56
1$\begingroup$ Improve your question by editing it, not adding to the comments. $\endgroup$– SpacedmanJul 22, 2014 at 16:57
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.
$\begingroup$ 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? $\endgroup$– 10landJul 22, 2014 at 15:32
1$\begingroup$ @jithinjustin there aren't data analysis tools built into mongo, or really any database. Also,
jsonis 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. $\endgroup$– indicoJul 22, 2014 at 17:39
1$\begingroup$ 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. $\endgroup$ Jul 25, 2014 at 2:56
1$\begingroup$ @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. $\endgroup$– indicoJul 25, 2014 at 21:59
$\begingroup$ 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. $\endgroup$ Jul 26, 2014 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.
$\begingroup$ Here is a related question regarding NoSQL, JSON, and Drill: datascience.stackexchange.com/questions/9568/… $\endgroup$ Dec 31, 2015 at 20:54
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.
$\begingroup$ 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. $\endgroup$ Jul 25, 2014 at 14:07
1$\begingroup$ Postgres + C, Python, Perl, R, feed your Postgres DB into the latest machine learning algorithms. Easy: postgresql.org/docs/9.0/static/xplang.html $\endgroup$ Jul 25, 2014 at 15:00
$\begingroup$ Nice. I'll have to try that out sometime. How about MySQL? $\endgroup$ Jul 25, 2014 at 15:16