How to represent relationships, when there may be 1 <-> thousands
sean at basho.com
Sun Feb 5 12:33:59 EST 2012
Links are great when small in number, but run into issues when more numerous, including HTTP header size limitations, plus the extra storage overhead of bucket+key+tag on disk. I recommend using secondary indexes for this problem, but you will need to be using the LevelDB storage engine.
Another possibility is to use an OR-set (CRDT) in a secondary key, as you suggest. The difference between an OR-set and a flat list is that the former will converge easily when there are conflicts.
On Feb 5, 2012, at 7:36 AM, Nicolas Petton <petton.nicolas at gmail.com> wrote:
> We're working on a replacement of the old Smalltalk project hosting
> website http://squeaksource.com/
> For this app we'd like to use Riak, using the Smalltalk client
> You can think of SqueakSource as a Github-like app specific to Smalltalk
> Now, my problem is we have a following/followers feature in the new app:
> users can follow projects.
> Some projects may have thousands of followers. We need to be able to get
> followers of a projects *and* projects followed by an user quickly.
> Typically, an user will follow a few projects, so this part is easily
> solved with links. It becomes more complicated when it comes to getting
> all users following a specific project, since it can be thousands, using
> links looks like a bad idea.
> I thought of the following solution, but I may be completely off the
> - users have links to projects they follow.
> - projects don't have links to the users following them, but a link to
> 'following/projectKey'. This object represents the relationship itself,
> and contains the list of the names of users following the project in a
> JSON array.
> This means following a project represents 2 writes, the user with the
> link, and the 'following object'.
> Does that seem reasonable?
> riak-users mailing list
> riak-users at lists.basho.com
More information about the riak-users