0

I have the following table:

  • attribute 1
  • attribute 2
  • attribute 3
  • attribute 4 -> de-dupe key
  • attribute 5 ->state
  • UUID.

And a service built on top of this for CRUD.

The initial state of the item is 'active'. If the CRUD API createItem is called, I need to check if an item with the same de-dupe key and 'active' state is already present, if so, I need to modify this item else create a new item for the same de-dupe key with 'active' state.

I cannot have GSI on de-dupe key and ensure the singleton nature. When an application writes or deletes items in a table, any global secondary indexes on that table are updated asynchronously, using an eventually consistent model.'

However, there are other ways to achieve this:

  1. Have a different table to have de-dupe key (as primary key) and active item UUID as the only attribute. So, the DAO interacts with both the tables for interactions. This is painful since the DAO has to deal with 2 tables (handling atomicity could be difficult).

  2. Have de-dupe as the PK and timestamp as the sort key. Except for the active item keep the timestamp 0. And perform conditional updates to it until its state changes. But, with this approach, I will lose the ability to perform batchLoad/batchGet on UUID, since the de-dupe key is PK.

Any ideas would be appreciated. Thanks.

StabCode
  • 106
  • 1
  • 6
user7365614
  • 469
  • 2
  • 4
  • 14
  • what is the current pk for the table? what is the relation between UUID and de-dupe key? How are you doing a get by de-dupe key if you don't have gsi on it? Is evantaul consistency a problem? – best wishes Jan 14 '20 at 02:39
  • I don't have the table as of now. There is no relation between UUID and de-dupe key. Eventual consistency would be a problem with GSIs since concurrent executions of createItem would create multiple items with state 'active'. – user7365614 Jan 14 '20 at 19:00
  • Any thoughts on this? – user7365614 Jan 26 '20 at 10:33

0 Answers0