开发者

Use cases for NoSQL [closed]

开发者 https://www.devze.com 2022-12-31 05:35 出处:网络
Closed. This question is opinion-based. It is开发者_JAVA技巧 not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citati
Closed. This question is opinion-based. It is开发者_JAVA技巧 not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 6 years ago.

Improve this question

NoSQL has been getting a lot of attention in our industry recently. I'm really interested in what peoples thoughts are on the best use-cases for its use over relational database storage. What should trigger a developer into thinking that particular datasets are more suited to a NoSQL solution. I'm particularly interested in MongoDB and CouchDB as they seem to be getting the most coverage with regard to PHP development and that is my focus.


Just promise yourself that you will never try to map a relational data model to a NoSQL database like MongoDB or CouchDB... This is the most common mistake developers make when evaluating emerging tech.

That approach is analogous to taking a car and trying to use it to pull your cart down the road like a horse.

It's a natural reaction due to everyone's experience of course, but the real value in using a document database is being able to simplify your datamodel and minimize your suffering as a developer. Your codebase will shrink, your bugs will be fewer and easier to find, performance is going to be awesome, and scale will be much simpler.

As a Joomla founder I'm biased :-) but coming from the CMS space, something like MongoDB is a silver bullet as content maps very naturally to document systems.

Another great case for MongoDB is real-time analytics, as MongoDB has very strong performance and scale particularly regarding concurrency. There are case studies at the MongoDB.org website that demonstrate those attributes.

I agree with the notion that each database has its own aims and use cases; take the purpose of each database for evaluation accordingly.


Some great use-cases - for MongoDB anyway - are mentioned on the MongoDB site. The examples given are real-time analytics, Logging and Full Text search. These articles are all well worth a read http://www.mongodb.com/use-cases

There's also a great write-up on which NoSQL database is best suited to which type of project: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis


I'd suggest this article by Rick Cattell about miscellaneous data stores (a.k.a. NoSQL), their differences and some of their use-cases: http://www.cattell.net/datastores/index.html


I have been using NoSQL DBs for a while now, and this is my contribute to the topic:

A great use case for a NoSQL database is an application for statistics and / or reports generation, expecially when data is provided from a third party source.

In a situation like that a NoSQL database can be a great choice

Let's consider, for example, MongoDB:

Once you have your data in JSON, ( it could come from a third party API, or be exported from an sql-application) in MongoDB is pretty strightforward to import and update the JSON data in the database; for example using the command-line mongoimport utility

At this point is very simple to build dynamic queries with filtering and grouping, that well fit with this kind of application.

For example, using the Aggregation Framework:

$pipeline = [];

//filter by date
$pipeline[] = [ '$match' => [ 'created_at' => [ '$gte' => $starDate, '$lte' => $endDate ]  ]  ];

//if we want to filter by a specific field, we add the filter to the pipeline array
if( $filters->isFilterByField() )
    $pipeline[] = [ '$match' => [ 'field' => $fieldValue ] ];    

//group the results by date and get the count
$pipeline[] = [ '$group' => [ '_id' => '$created_at', 'num_elements' => [ '$sum' => 1 ] ] ];

return $collection->aggretate( $pipeline );

I'd like to point up the easiness with which we can dinamically add/remove filters using php data structures and avoiding tedious string concatenation to build up our queries. With this approach adding/removing filters dinamycally is as easy as adding / removing elements from an array

Another great benefit comes from the fact that a solution like this is likely to be faster than using a relational database, where we have to make joins with different tables to get all the data we need

Besides, this use case is optimal because avoids all the principal limits of a NoSQL database:

  • Lack of transactions: The application doesn't perform writes but only reads, so we don't need transactions at all

  • Lack of joins between tables: We don't need joins, as we can use redundancy to store our denormalized data in the collections. As we only read data, we don't need to be worried about synchronizing denormalized data among updates.

This way we can focus on storing the data with redundancy in a manner that well fits to our queries, that will be focus on single collections.

I'm just writing this because had i read something like that some times ago, it would have been saved me some time to make researches

Hope it will be useful to someone


What I like about NoSQL has nothing to do with performance and everything to do with usability. Document stores are just easier to work with when your atomic data units are document-like, because it's trivial to serialize to and from objects. It's just more fun, and that's an important factor for personal or side projects.


I strongly recommend this talk by Martin Fowler:

https://www.youtube.com/watch?v=qI_g07C_Q5I

ABSTRACT: Martin gives a rapid introduction to NoSQL databases: where they came from, the nature of the data models they use, and the different way you have to think about consistency. From this he outlines what kinds of circumstances you should consider using them, why they will not make relational databases obsolete, and the important consequence of polyglot persistence.

It draws a nice picture of what NoSQL is, the different categories and the things everyone has to understand when coming from relational databases world. Regards.


First you have to understand CAP (Consistency, Availability and Partitioning, where you have to pick-up two of three) theory and our Business use case. MongoDB satisfies Consistency and Partitioning & Couch DB satisifies Availability & Partitioning.

Edureka videos in youtube regarding NoSQL are some of the best video tutorials.

https://www.youtube.com/watch?v=gJFG04Sy6NY

https://www.youtube.com/watch?v=KSq6tMMXZ8s

https://www.youtube.com/watch?v=3z1KFA2qcSo

Good presentations are available in slideshare.net

http://www.slideshare.net/quipo/nosql-databases-why-what-and-when?qid=3bb9f7f6-a53d-41b1-8403-cd6f181d0ca7&v=qf1&b=&from_search=1

http://www.slideshare.net/EdurekaIN/no-sql-databases-35591065?qid=f1b9c095-6d70-4d0a-91da-1df664c4f389&v=qf1&b=&from_search=3 (This presentation supports video tutorial in youtube)


For some use cases you need, especially for analytic queries you can run SQL queries on MongoDB with this wrapper from Postgres.


Because there are now many more NoSQL databases on the market than ever before, I suggest having a look at the Gartner Magic Quadrant if you're looking for a database that will also be great for enterprise applications based on support, expandability, management, and cost.

http://www.gartner.com/technology/reprints.do?id=1-23A415Q&ct=141020&st=sb

I would like to suggest Couchbase to anyone who's not tried it yet, but not based on the version that is shown in the report (2.5.1) because it is nearly 2 revisions behind where CB Server is today, nearing release of 4.0 in 2H15.

http://www.couchbase.com/coming-in-couchbase-server-4-0

The other part about Couchbase as a vendor/product is that it is a multi-use type of DB. It can act as a pure K/V store, Document Oriented Database with multi-dimensional scaling, Memcached, cache-aside with persistence, and supports ANSI 92 compliant SQL with automatic joins, replication to DR clusters with the push of a button, and even has a mobile component built-in to the ecosystem.

If nothing else, it's worth checking out the latest benchmarks:

http://info.couchbase.com/Benchmark_MongoDB_VS_CouchbaseServer_HPW_BM.html http://info.couchbase.com/NoSQL-Technical-Comparison-Report.html

0

精彩评论

暂无评论...
验证码 换一张
取 消