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:
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).
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.