User Tools

Site Tools


cloud:aws:dynamodb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
cloud:aws:dynamodb [2023/11/01 07:13] – removed - external edit (Unknown date) 127.0.0.1cloud:aws:dynamodb [2023/11/01 07:13] (current) – ↷ Page moved from business_process_management:camunda:cloud:aws:dynamodb to cloud:aws:dynamodb skipidar
Line 1: Line 1:
 +===== Dynamo DB =====
 +
 +=== Data ===
 +
 +The following table lists the data types you can use with PartiQL for DynamoDB.
 +
 +| Boolean | ''TRUE / FALSE'' | Not case sensitive. | 
 +| Binary | ''N/A'' | Only supported via code. | 
 +| List | ''[ value1, value2,...]'' | There are no restrictions on the data types that can be stored in a List type, and  the elements in a List do not have to be of the same type. | 
 +| Map | ''{ 'name' : value }'' | There are no restrictions on the data types that can be stored in a Map type, and  the elements in a Map do not have to be of the same type. | 
 +| Null | ''NULL'' |Not case sensitive. | 
 +| Number | ''1, 1.0, 1e0'' | Numbers can be positive, negative, or zero. Numbers can have up to 38 digits of precision. | 
 +| Number Set | ''<<number1, number2>>'' | The elements in a number set must be of type Number. | 
 +| String Set | ''<<'string1', 'string2'>>'' | The elements in a string set must be of type String. | 
 +| String | '''string value''' | Single quotes must be used to specify String values. | 
 +
 +<code>
 +INSERT INTO TypesTable value {'primarykey':'1', 
 +'NumberType':1,
 +'MapType' : {'entryname1': 'value', 'entryname2': 4}, 
 +'ListType': [1,'stringval'], 
 +'NumberSetType':<<1,34,32,4.5>>, 
 +'StringSetType':<<'stringval','stringval2'>>
 +}
 +</code>
 +
 +
 +=== Indexing ===
 +
 +| Partition Key \\ \\ (alias "Hash Key" | A column, chosen to be hashed, to distribute data on DB-nodes. \\ \\ This is part of the reason DynamoDB is so scalable. Because it can hash your data inputs into an arbitrary number of storage nodes \\ \\ https://www.beabetterdev.com/2022/02/07/dynamodb-partition-key-vs-sort-key/|
 +| Sort Key \\ \\ (alias "Range Key") |<WRAP> is a **secondary DB key**  that you can **optionally** decide to use alongside your Partition Key. \\ \\  if you decide to **only specify a partition** key and **not a sort key**, all **records must have a unique partition key value.** In other words, you will only be able to have one record with CustomerId as CID-123. \\ {{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/sharex/Bcio1TH0N5.png?200}} \\
 +
 +By using a Sort key, we’re also able to perform what I call “range-like” queries on our Sort Key values.
 +
 +  * = (equal to)
 +  * <= (less than equal to)
 +  * >= (greater than equal to)
 +  * > (greater than)
 +  * between
 +  * begins with 
 +  * sort ascending / descending
 +</WRAP>|
 +| Composite primary Key | Partition key + Sort Key |
 +| Local Secondary Indexes \\ \\(LSI) |<WRAP> 
 +Local Secondary Index  is like an **additional sort-key**. \\
 +**Relies on Partition Key**. \\ 
 +You can have **max. 5 of LSI**.
 +
 +  * partitionKey+sortKey1
 +  * partitionKey+sortKey2
 +  * .. partitionKey+sortKey6.
 +
 +https://stackoverflow.com/questions/21381744/difference-between-local-and-global-indexes-in-dynamodb
 +
 +Facts: 
 +  * Limit you to only **10GB of data per Partition Key**.
 +  * Unlike GSIs, they **share throughput with base table**. \\ \\ If you query for data using LSI, the usage will be calculated against capacity of the underlying table and its base index.
 +  * They have to be **specified at table creation**. you can't add or remove them after provisioning the table
 +
 +</WRAP>|
 +| Global Secondary Indexes \\ \\ (GSI) |<WRAP> 
 +DynamoDB global secondary index is a type of index containing a **partition key** and a **sort key different from the base table's primary key**. 
 +
 +It is known as the **"global"** secondary index **since the queries on the index can access data from multiple partitions** of the base table.
 +
 +{{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/sharex/JHdZJlc0q5.png}}
 +</WRAP>|
 +| Sparse index |<WRAP> 
 +Sparse Index is a **special type of GSI** that allows you to **index only a subset of the collection** by **indexing an attribute that is not present on all** the items. 
 +
 +This technique is useful to **quickly query for a set of items that have a specific attribute value**, e.g. only rows that have an attribute deletedAt defined. 
 +
 +To create a sparse index, make sure that **only items that should be in that index** - **have a value** of that index-sort-key  present.
 +
 +{{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/sharex/rcf4u5eUyL.png?350}}
 +</WRAP>|
 +| Inverted index |<WRAP> 
 +Inverted Index is a GSI that is basically a primary key but inversed - table's hash key becomes inverted index's sort key and table's sort key becomes inverted index's hash key.
 +
 +{{https://s3.eu-central-1.amazonaws.com/alf-digital-wiki-pics/sharex/rhvP4HFkPX.png?350}}
 +</WRAP>|
 +
 +=== QA ===
 +
 +**Question:**
 +When to use this one, when to use a relational DB?
 +
 +
 +**Answer:**
 +The Dynamo DB has a limited indexing-ability 
 +
 +
 +Glossary:
 +
 +|Term|Value|
 +|Term|Value|
 +|primary key|Value|
 +|sort key|Value|
 +|Global secondary index|Value|
 +|Local secondary index|Value|
 +|Term|Value|
 +
 +
 +=== Query vs Scan ===
 +
 +https://dynobase.dev/dynamodb-scan-vs-query/
 +
 +{{https://dynobase.dev/dynamodb-scan-vs-query/}}