Reputation: 11159
Since Riak uses buckets as a way of separating keys, is it possible to have buckets within buckets? If not how would one go about organizing a Riak setup with many buckets for several apps.
The basic problem is how one would go about representing "databases" and "tables" within Riak. Since a bucket translates to a table, what translates to a database?
Namespaces in programming languages usually have hierarchies. It makes sense for Riak buckets to also allow hierarchies, since buckets are essentially namespaces.
Upvotes: 3
Views: 1227
Reputation: 3637
You need to think about Riak as about very big key -> value
"table" where buckets are only prefixes for keys. Now when you know that you can do anything with buckets as long as they are still binary objects.
You can create linear "tables":
<<"table1">>
<<"table2">>
Or you can create hierarchies:
<<"db1.table1">>
<<"db1.table2">>
<<"db2.table1">>
<<"db2.table2">>
Or you even can use tuples as buckets:
1> term_to_binary({"db1", "table1"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,49>>
2> term_to_binary({"db1", "table2"}).
<<131,104,2,107,0,3,100,98,49,107,0,6,116,97,98,108,101,50>>
3> term_to_binary({"db2", "table1"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,49>>
4> term_to_binary({"db2", "table2"}).
<<131,104,2,107,0,3,100,98,50,107,0,6,116,97,98,108,101,50>>
Upvotes: 10