0
votes

I am building an application using AWS Mobile HUD and connected services, most prominently Cognito & DynamoDB. Currently I am facing a problem to setup a scheme that allows me to store user-related information on DynamoDB items (or vice versa).

Scenario

Run 1

  1. User A pulls list of [RootItem] = {RootItem_1, RootItem_2, RootItem_3} from DynamoDB (check: works fine)
  2. User A either dismisses RootItem_1 (mark as 'not interested' in app)

Run 2

  1. User A logs into the application
  2. User A pulls list of [RootItem] = {}
  3. User A should only get RootItems which are not dismissed
  4. List delivered to client should be {RootItem_2, RootItem_3}

Being new to non-relational data / NoSQL, I am not sure what is the best way to approach this. Possible Ideas:

  • Store userID on the RootItem_1 to exclude it in Scan [issue: there will potentially be thousands of users dismissing the same item]
  • Store uuid of RootItem_1 to userdata on cognito, cache locally before pull and exclude uuid's from pull
  • Create table with exclusions/dismissions [userid, rootItem_uuid], query this first to get list of user exclusions. > potential performance issue?

It would be great to get some advice what is the best approach to handle this in a NoSQL environment.

1
It was a looong time ago I tried out dynamodb, but you should avoid SCAN operations if possible, it is very heavy. Have you looked into Global Secondary Indexes? Which might reduce the need for SCAN operations and allow you to query on your table instead. docs.aws.amazon.com/amazondynamodb/latest/developerguide/… - user5890979
i am aware that scans are not perfect, the problem is that i have to do rather complex queries which seem to be impossible using query. aka {property 1 == x && property 2 beween (a, b) or (c, d) && property 3 = a or b, ...} in total i am looking to filter for ranges & matches on 6-7 different properties, with OR and AND operations, and so far I think with query this is not possible - Sebastian Flückiger
That was the reason we moved out of DynamoDB. It is excellent when you don't need to do "advanced" querys, but you run into a wall when you need some more conditions. That, and together with this: stackoverflow.com/questions/41520123/… check out my answer NOTE on that question. Since you are using Cognito and iOS I assume you are connecting directly to DynamoDB, that is something to be aware of also (not to scare you away). - user5890979

1 Answers

0
votes

It depends of course on the number or RootItems, and how many active (not dismissed) RootItems are existing per user. But I would maintain a list of RootItems (or refereces to it) and store it in a table for each user, and maintain that list as the user dismisses the items. Or even is it possible that most items are dismissed, and then it would be a list of saved items for the users?