I am working on creating a DynamoDB table to store comments related to a single object.
Comments are sent to the object at a specific time, I use the time posted as a range, so comments are sorted in descending order of time. I have a global secondary index userId of the user who posted the comment, this should allow me to get all the comments posted by this user.
My question is, will this key be unique? I am worried that since it is technically possible for two users to leave a comment on the same object at the same time, the comment hash and range key will be identical.
My hope is that since it should not be possible for the same user to post two comments on the same object, the global secondary index will make the key unique.
Comment table: Hash Key Range Key Global Secondary Index Hash --------------------------------------------------------------------------------------- | objectId | datePosted | userId | | (not unique) | (not unique if multiple users | (unique across objectId and | | | post for the same object @ same time) | datePosted) | ---------------------------------------------------------------------------------------
source share