I am looking for help on design the dynamodb table. Here is my usecase,
Currently, i have a set of actions that user can complete at any point of time. These actions keep on changes based on the user actions on account level by group. And these actions are grouped. meaning, user can belong to multiple groups. i wanted to track these actions in dynamo table.
i did came up with two designs in dynamo. i am not sure, which has better approach according to dynamo standards.
Design-1
accountid (PK) -- groupName (SK) -- json
1234567891023 -- groupName1234 -- { clicked: true, opened: true }
Note: Here JSON won't be reaching more than 20kb.
Design-2
accountid (PK) -- groupName (SK) -- action -- status
1234567891023 -- groupName1234 -- clicked -- true
1234567891023 -- groupName1234 -- opened -- true
And we are expecting to have more than 2 million records to start with. Based on the data, which design would be the good option here?
operations we are planning to do on this table
I am not sure, whether to go with a JSON-based data model or a top-level attribute-based model.
Your basically asking if you should store your data as nested JSON or as top level attributes? As your keys don't change, both models are equal for your access.
However, storing as top level attributes can provide better flexibility, you can create an index on an attribute of needed for example.