DynamoDB Schema Design for storing Certificates in Database

21 views Asked by At

We are modeling schema in dynamoDB for persisting certificates.

Each certificate will have attributes like name, type, state, location, issueDate, expiryDate, discontinuedDate, etc.

We are thinking of storing that in DDB with PK as certificateID (uuid) and SK as ( CERT-timestamp). This will help in achieving uniform distribution of data. Any suggestions on if something other can be looked upon for PK-SK combination.

The other question is, we want to fetch all the certificate which will get expired in next 90 days. To fetch that, we are thinking of creating a GSI that will hold PK as expiryYearMonth(a new column that we will create out of expiryDate). This will help us fire 3-4 queries in DDB and get the records of interest. Any concerns on this approach or any other better approach can someone suggest?

I tried giving a thought and expecting if I can get some other perspective on this.

1

There are 1 answers

0
Leeroy Hannigan On

The PK and SK of your base table should be defined based on your access patterns, but you didn't list any. But what you described is well distributed.

For your lookup of expiring certificates, what you explain would work but there may be a more optimal solution depending on your throughput. If your overall write throughput does not exceed 1000 WCU and never will, then a static partition key for your index would work well, allowing you more fine grained control on your sort key. If you need more throughput then you can shard the key. This blog post explains it in more detail.