Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Links in Riak: what can they do/not do, compared to graph databases?

Tags:

riak

The familiar Neo4j treats relationships as first class citizens; ad hoc queries/ traversals, integrity (if one node is deleted, the link is gone) etc. It also advertises as the only mechanism to denote relations as well as outperform joins of relational DBs.

How powerful are Riak links to denote relationships? Can they be used to answer ad-hoc queries like "fetch a list of hobbies for each such person who earns more than x" or friend of a friend, assuming suitable features like secondary indexes? In general, can they simulate the output of a join in an RDBMS?

Are they also meant for heavy use, such as a social bookmarking system where there are lots of links for a person and bookmarks? Or are they meant for careful use (all structures must be directed acyclic graphs)?


In the "not do" category:

  1. Link integrity is not enforced
  2. It cannot answer "what links to this node?"
like image 335
Jesvin Jose Avatar asked Mar 17 '12 17:03

Jesvin Jose


People also ask

When would you use a graph database?

Graph databases have advantages for use cases such as social networking, recommendation engines, and fraud detection, when you need to create relationships between data and quickly query these relationships. The following graph shows an example of a social network graph.

What is NoSQL graph database?

The NoSQL ('not only SQL') graph database is a technology for data management designed to handle very large sets of structured, semi-structured or unstructured data. It helps organizations access, integrate and analyze data from various sources, thus helping them with their big data and social media analytics.


2 Answers

Links in Riak are just some metadata (list of one-way references to foreign keys) stored along with value. They are usually used as an input to MapReduce that can do whatever you want with them, including simulation of RDBMS joins.

There are no integrity checks or any additional magic in them like finding reverse links. They are just a convenience API, absolutely the same could have been achieved by storing these lists of foreign keys inside the values, serialized in some way.

For social bookmarking example I'd recommend using Riak Search, because it allows more flexible queries like http://example.com/* and have proper distributed indexing and lookups.

like image 88
Ivan Blinkov Avatar answered Dec 11 '22 07:12

Ivan Blinkov


blinkov's answer is correct. No, Riak Links are not appropriate for the scenario that you describe. There is no referential integrity checking, and there is a limit to how many links you can store with each object (I believe, up to 255).

Riak Search is much more appropriate for a social bookmarking scenario. In fact, the social bookmarking site Clipboard uses precisely this mechanism - bookmarks as Riak objects, with Riak Search enabled on them (for tagging, event triggers and notifications, etc). When the Ricon 2012 conference videos go up online, I recommend you watch the Clipboard talk for some more details on this.

Riak + Secondary Indexes would also be an appropriate solution to a lot of these cases. See my answer to Which clustered NoSQL DB for a Message Storing purpose? and How to structure data in Riak? for schema suggestions for a similar setup.

like image 34
Dmitri Zagidulin Avatar answered Dec 11 '22 07:12

Dmitri Zagidulin