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

Nicolas Petton petton.nicolas at gmail.com
Sun Feb 5 07:36:22 EST 2012


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




More information about the riak-users mailing list