0

I'm creating a User Table on DynamoDB, and I wanted to set the primary key as a sha256 hash string of the user's email address.

Is it a good idea to keep a SHA256 value as a primary key in a DynamoDB table? Would this be better for lookups or worse?

kingnuni42
  • 11
  • 1

1 Answers1

0

The idea is that the primary key uniquely identifies each item in a DynamoDB table,
Which can be simple (a partition key only) or composite (a partition key combined with a sort key).

SHA-256 generates an almost-unique 256-bit (32-byte) signature for a text.
An alternative is using UUID V1 for being used as Primary keys,

Here's an interesting content on the use of UUID -
https://www.sohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/

Best Practices for Designing and Using Partition Keys Effectively -
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-design.html

Dev1ce
  • 5,390
  • 17
  • 90
  • 150