0:00
Hello everyone. In this video we are going to see the difference between
0:10
partition key and sort key in Amazon DynamoDB. The partition key is
0:18
nothing but a primary key for the table. The value in this primary key or the
0:25
partition key should be unique if sort key is not used. When we create Amazon DynamoDB table, the sort key is optional, but the partition key is mandatory or required
0:42
So if I create Amazon Dynamo table without sort key, then the entries in the partition key should be unique
0:53
Let's say I'm also going to use sort key. so sort key is nothing but secondary primary key for the table it is used for creating composite key when it is used Composite key is generated using partition key and the sort key
1:12
The combination of partition key and the sort key for each and every item in the table or the rows in the table should be unique
1:21
If you wanted to know more about composite key, please learn more about it so that
1:28
it will clarify all the basic doubts about composite key the combination of primary key and the sort key should be
1:36
unique when the sort key and primary keys are used and very important thing is the primary key if the partition key is used
1:46
its value should be unique since we don't have sort key to get unique
1:51
combination of values and another important thing to note is that dynamo db uses partition key value as an input to the internal ash function even if the shot key is used for both the combination with a table with partition key and a table without with the partition
2:12
key and shot key uses only the partition key as the internal hash function
2:19
will be used as an input in the internal hash function the output of this ash
2:24
function will get will determine where the item is stored so in amazon a w s
2:30
they have internal storage so this will this value will give us where exactly the data is
2:38
stored for that particular item so here I have two tables one is employee
2:47
with the just partition key and here I have another table called test where I have
2:56
Pk as the partition key and SK as the soft key important thing here
3:00
is the employee number should be unique in all the entries because I am not using sort key here Pk and S K combination of these values should be unique but same primary key i can use it for multiple items
3:16
but the combination of primary key and the secondary or the secondary key or the short key should be unique so this makes a big difference between
3:26
partition key and sort key I hope it was helpful