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

℡╲_俬逩灬. 提交于 2019-12-30 04:56:25

问题


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?"

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/9752036/links-in-riak-what-can-they-do-not-do-compared-to-graph-databases

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!