I have a data relationship of many Users to many Roles to many Permissions. The Users to Roles many to many relationship is handled in a single table using different indexes to represent which side of the many to many relationship you are on. I am trying to figure out how to get the permissions represented. Here is what I want to end up with using just one call to DynamoDB.
{
username: 'User Name',
roles: [
{
roelName: 'Role Name',
permissions: [{ permissionName: 'Permission Name' }],
},
],
}
I can make the same relationship between roles and permissions using the single table principle but how do I link the user all the way to the permissions.
Another option would be to keep the permissions denormalized and living with each role. I am not too found of this because I would have to update every role linked to a user when the roles permissions changed.
So how do you represent this relationship in DynamoDB and still keep the calls down to one ?