From DynamoDB Documentation
Hash key is your Partition key (Similar to a Primary Key in SQL). In a table that has only a partition key, no two items can have the same partition key value.
- True in the absence of a Sort key
Range key is your Sort key (Referred to as a Composite Key) - makes possible to have the combination of Hash Key + Range Key. The first attribute is the partition key, and the second attribute is the sort key
E.g.:
H1 + R1 -> H1R1 is one Composite Key.
H1 + R2 -> H1R2 is another Composite Key.
For a real world scenario, consider a case where there is one user but has multiple roles.
User Id itself can't be used for all the cases. User-Id + Role-Id makes for a unique composite key.