skip to Main Content

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

  • Retrieving all the actions that the account did
  • Retrieving all the actions that the account did by group

I am not sure, whether to go with a JSON-based data model or a top-level attribute-based model.

2

Answers


  1. 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.

    Login or Signup to reply.
  2. With top-level attributes you will be able to perform query operations over the table by other attributes expect the primary key & sort key, by adding secondary indexes for the table.

    If the combination of accountid & groupName (a record) may contain some complex data such as aggregations and multi level hierarchy objects, it can be more convenient to use JSON.

    So if the tables attributes will stays as now – "primitive" types it would be better for flexibility to declare it at top level.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search