DEV Community


Discussion on: Working With Hierarchy Data In DynamoDB

jasonwadsworth profile image
Jason Wadsworth Author

There are certainly many variations on how you might do the path base pattern. I chose to put the root in the partion key to avoid a hot partition, which you would get with a hard coded "Path". That said, most often I'm in a multi-tenant environment where there is an identifier for the customer, so I'd likely put the customer's ID in the partition and put the entire path in the sort key, as you showed in your first example.

On the second example, you'd have to have duplicated data to use the full path in the partition key, unless you only wanted to get data directly below a node. You have to provide the entire partition key on all query operations, so you can't do something like begins_with(pk, 'DriveA#') if you wanted everything below 'Drive A'.

zachjonesnoel profile image
Jones Zachariah Noel

Understood. Yea having a query with partition key and operating with begins_with is not possible.