Hi,
I read that when setting a value I can choose a key name or let Riak come up
with a name for me. The majority of examples in the docs seem to choose
names. However, it seems like anytime you'd store "table"-ish data, you'd
want to avoid choosing names for your keys ("rows") and let Riak do it, right?
For example, suppose I want to store some user data, and I let users change
their usernames whenever they want. Here's a natural first pass at a schema:
/users/{user_fixed_id}:
data: user data
/users_by_name/{username}:
data: empty
link: /users/{user_fixed_id}
Here I have the real user data keyed by some fixed id, and then pointers to
those objects keyed by name. If the user ever changes his name I delete the
old pointer and create a new one.
"users" is basically the table then, and I let Riak choose the ids. I have to
put the index ("users_by_name") as a different bucket so that Riak ids don't
conflict with potential usernames. Unless there is a way to control how Riak
chooses its ids (like choosing key name prefixes), I think you pretty much have
to split into a bucket right?
Alternatively, the client could generate the fixed value itself, allowing it to
use key name prefixes in the same bucket (e.g. "user_{user_fixed_id}" and
"username_{username}"}. Generated ids would most certainly have to be UUIDs,
though it might be interesting to know if an auto-increment integer is
possible, if the integer is stored in Riak.
I'm just trying to get an idea of how people go about this.
Thanks,
Justin
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com