amazon-web-servicescassandraamazon-dynamodbtimeuuid

Cassandra TimeUUID in DynamoDB


I am migrating an application from Cassandra to DynamoDB. On Cassandra we used as key a combination of (entityName,TimeUUID), with DynamoDB as far as I have read I could use a Hash+Range Primary Key.

To mantain the same data structure of the Cassandra Database I have been thinking of using entityName as Hash and timestamp as range. Then, I thought that maybe the timestamps might not be Unique: I am speaking of corner cases, but the Cassandra Primary Key (entityName,TimeUUID) is more powerful than the DynamoDB Hash+Range (entityName, timestamp), since it allows the existence of elements with the same entityName and timestamp.

Can I use Cassandra's TimeUUID as DynamoDb's range? Are there any reason why I should not use this approach?


Solution

  • You can (and should, if you think you can have collisions on timestamp). The only catch, I can think of, is that you might have to handle between time_x and time_y Query on your own.

    For e.g., let's say you have these 5 items in your table:

    Also, assume that t1 < t2 < t3 and UUIDs are 4 character strings between aaaa and zzzz

    Now, if you need all items with HK h1 and RK between t1 and t2, then your Query would contain something like between t1_aaaa and t2_zzzz.

    This is because DynamoDB does not, on its own, understand the concept of TimeUUIDs like Cassandra. So, you'll have to handle cases such as above in your application layer.