I am currently building a simple newsletter app, where users can get invited via their emails to read a newsletter.
I have the current example table setup:
I use 1 GSI, which uses base table SK as PK and base table PK as SK - this gives me the following aggregated view:
My question is - for my use case, the "newsletter email relationship data" and "newsletter data" has to be identical, so that I can show a preview of my newsletters in the newsletter list and at the same time, display newsletter itself after the user clicks on one of the listed newsletters and displays the newsletter detail.
For anyone trying to understand dynamoDB and appsync the same way I did. You dont need to save most of your data redundantly the way I did in this example. You can actually define a relationship between your newsletter and your newsletter application and just fetch the newsletter data straight from the invitation as such as in the example below:
type Newsletter {
id: Int!
name: String!
description: String!
}
type NewsletterInvitation {
id: Int!
email: String!
newsletter: Newsletter!
}
This should give an answer to most of the people coming across this post.
For any use cases regarding SK modifications, it gets more difficult. You will need to use dynamodb data streams, SQS fronts and possibly custom lambda triggers to listen to your specific Item change, creating an SQS event or triggering a lambda and doing the modifications of the newsletter invitation sort keys manually.