How to represent relationships, when there may be 1 <-> thousands

Jeremiah Peschka jeremiah.peschka at gmail.com
Sun Feb 5 12:37:48 EST 2012


For everyone only familiar with the Cambodian Rural Development Team, here is a link to a GitHub CRDT project: https://github.com/ericmoritz/crdt

---
Jeremiah Peschka, MVP
Managing Director, Brent Ozar PLF, LLC

On Feb 5, 2012, at 9:33 AM, Sean Cribbs <sean at basho.com> wrote:

> Hi Nico,
> 
> 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. 
> 
> Sean Cribbs
> 
> On Feb 5, 2012, at 7:36 AM, Nicolas Petton <petton.nicolas at gmail.com> wrote:
> 
>> Hi!
>> 
>> 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
>> http://www.squeaksource.com/Phriak
>> 
>> You can think of SqueakSource as a Github-like app specific to Smalltalk
>> code. 
>> 
>> 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
>> tracks:
>> 
>> - 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?
>> 
>> Thanks,
>> Nico
>> 
>> 
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com



More information about the riak-users mailing list