1
votes

We are investigating on choosing a nosql database for our web service. We have tried Cassandra and successful model our original MySQL data using Cassandra column family and super column family. It's a pretty interesting experience. Now, we start to look into Riak and wondering how the Cassandra's super column family be modeled using Riak.

For example we have a super column family to store all the friends of a user, with the user's id to be key, timestamp when the friend was connected as secondary key, and the key value pairs for the friend in the node column family.

uid1 ---- t1 ---- key1 : value11
                  key2 : value12

          t2 ---- key1 : value21
                  key2 : value22

          ...     ...    ...

uid2 ---- tm ---- key1 : valuem1
                  key2 : valuem2

          tn ---- key1 : valuen1
                  key2 : valuen2

          ...     ...    ...


uidx ---- .... 

With the above data modeling, one usage is that we can do range query to get all (or a given count of) the friends of an user (uid1, e.g.) connected within a given time range.

With Riak, how the data should be modeled to achieve the usage scenario above?

1

1 Answers

1
votes

In Riak you would use Links. You would store the user information, the friend's user information, then create a "link" from one friend to another. This can be bi-directional if you want.

Link: </riak/users/alice>; riaktag="bob"