Keys

Jeremiah Peschka jeremiah.peschka at gmail.com
Wed Oct 10 10:01:23 EDT 2012


Hi Tom,

With Riak, you load your data by primary key. Just like you have to specify a PK for a row with Cassandra or an RDBMS, you specify one with Riak. Riak "knows" all those values belong to the PK because you store them as an opaque blob within Riak. 

Using curl, loading your object would look like:

curl -v -XPUT -d '{ "name": “Gunther Boss”, "date of birth" : “1/1/1980”, "postal code" : "12345", "customer type" : "retail" "date became customer" : "1/1/2005", "purchase frequency" : "5"}' -H "Content-Type: application/json" \
  http://127.0.0.1:8091/riak/customer/123

Instead of timestamps, Riak creates a vector clock. This helps you determine object lineage as opposed to the time something was last saved. 

I suggest running through the Riak FastTrack[1]. It takes about 45 - 90 minutes, but it'll give you a great overview of the concepts behind Riak and how you can use them to kick ass.

[1]http://docs.basho.com/riak/latest/tutorials/fast-track/
--- 
Jeremiah Peschka - Managing Director, Brent Ozar PLF, LLC
Microsoft SQL Server MVP

On Oct 9, 2012, at 10:30 PM, Tom Haughey <thaughey at gmail.com> wrote:

> I just attended the Webinar on Intro To Riak. It did not say much about schema design, just the one page. That is what I focus on. So let me ask a question.
> 
> Say we have a bucket called Customer with Customer No : “123”. This customer has attributes (key : value pairs) of: name : “Joey Brown”, date of birth : “1/1/1980”, postal code : “12345”, customer type : “retail” date became customer : “1/1/2005” purchase frequency : “5”
> 
> The JSON could be:
> 
> { "name": “Gunther Boss”, "date of birth" : “1/1/1980”, "postal code" : “12345”, "customer type" : “retail” "date became customer" : “1/1/2005”, "purchase frequency" : “5”}
> 
> How does Riak know that these attributes all belong to Customer 123? That Customer No is the ID? How do we specify the id for the whole row?
> 
> Cassandra uses the following:
> 
> RowId + Column Family + Column Qualifier + Timestamp + Value (or Payload). (RowId + Column Family + Column Qualifier + Timestamp provide uniqueness). The key is Column family + Column Qualifier
> 
> I believe I would assign Customer ID as the key to the bucket (Customer), and the rest of the data would be stored in a string or blob. The application would be responsible to decompose the string into the appropriate fields. In my example above, there is one row containing key = 123, and the above document as the value { "name": “Gunther Boss”, "date of birth" : “1/1/1980”, "postal code" : “12345”, "customer type" : “retail” "date became customer" : “1/1/2005”, "purchase frequency" : “5”}. How do I actually specify the key? In the JSON example, is there a reserved word or expression to indicate what the key is? Or how do you actually specify the key in RIAK?
> 
>  
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20121010/8e1726b0/attachment.html>


More information about the riak-users mailing list