r/dynamodb • • Apr 29 '20

What is the most efficient table structure?

I am creating a new project and I would like to discuss about the structure of the future dynamodb table.I have an application that read a text and send each line for an analyze. This analyze will check in dynamodb if alerts have to be sent. I would like to give the possibility to the users to create their own alerts (store in dynamodb).

For example :

  • user1 wants to receive notifications when a line contains "hello" and "home"

  • user1 wants to reiceve notifications when a line contains "hello"

  • user1 wants to reiceve notifications when a line contains "hello" and "home" and "fun"

The following line will send two alerts :hello home

Which structure would you use to store alerts in order to have the best performance for the analyze?

1 Upvotes

3 comments sorted by

1

u/holi74 Apr 29 '20

I'm thinking about creating one boolean column per word but I think it's not a good idea for the query

1

u/revicon Apr 29 '20

For your example cases:

1)
  PK: USER#user1#FILTER
  SK: filter_id_1
  item body: {
      rules: [
          {
              "type": "contains",
              "filter_on": "hello"
          },
          {
              "type": "contains",
              "filter_on": "home"
          }
      ]

2)
  PK: USER#user1#FILTER
  SK: filter_id_2
  item body: {
      rules: [
          {
              "type": "contains",
              "filter_on": "hello"
          }
      ]

3)
  PK: USER#user1#FILTER
  SK: filter_id_3
  item body: {
      rules: [
          {
              "type": "contains",
              "filter_on": "hello"
          },
          {
              "type": "contains",
              "filter_on": "home"
          },
          {
              "type": "contains",
              "filter_on": "fun"
          }
      ]

1

u/holi74 Apr 30 '20

With this example, the query won't be good because I'll need to add all possible combinations.