Reputation: 137
I know AWS questions are rarely getting an answer but I will try my luck. It's a pretty easy one but I cannot find an answer to that
Let's say I have the simples table ever with 2 'column'. token
(Partition Key) and userId
What I want is to have a 1000 of tokens, and once a user signs up, a token will get assigned to the user. Basically the userId
property in the table will be populated. Also, I want to be able to query, not scan, by both token
and userId
In order to query by userId
I can use it as a GSI, BUT it states that GSIs should not be null. All my entries in the beginning will have the token
property, but the userId
will be empty until it actually gets assigned.
What can I use for this scenario? I thought about a Sort Key as it's a Sparse Index, but as far as I know I cannot query ONLY by the Sort Key itself.
Upvotes: 0
Views: 157
Reputation: 7132
Just do what you’re thinking there and create a GSI based on the userID. For the base table don’t include a userID attribute at all until the token has one. This isn’t relational. You don’t need every row to have all attributes. Only the key attributes have to be provided.
So:
Upvotes: 1