Wrapping my brain around DynamoDB | Snowulf
In DynamoDB, the primary key can be one of two types: "Hash" or "Hash and Range". The primary key must be unique, just like a primary key in a RDBMS. If you're using Hash and Range, the combo of the two must be unique (so you can have several records with hash of "a", as long as the range is unique). Keep in mind that string type fields are case sensitive, so you hash "a" != hash "A". Now, once you've entered values into your Dynamo primary key, you cannot modify it. In MySQL, you can modify primary key values (even if they are set to be unique). Now, one clarification, the word "range" in "Hash and Range" really doesn't mean anything (that I can tell). Your range can be something like a date/time stamp, or it can be a string value, doesn't matter – as long as the hash/range combo are unique.
What about indexes? Well in a RDBMS, any field or combo of fields you'll be querying – you want to index (though this depends on the RDBMS you use, and how exactly you want to index). In Dynamo, there are a number of limitations on "local secondary indexes" (LSI). First and foremost is that you can only have LSIs if you have a Hash and Range primary key. The second limit is that LSIs are single attribute only (DynamoDB calls them "attributes", RDBMS would call them a column). Third, you can only have 5 LSIs per table. Lastly, you cannot add/modify/remove LSI after you've created the table. Since this is NoSQL, all attributes beyond your primary key are flexible – but if you want to use LSI, plan
Read full article from Wrapping my brain around DynamoDB | Snowulf
No comments:
Post a Comment