Skip to content

Instantly share code, notes, and snippets.

@jdecode
Last active September 4, 2020 11:22
Show Gist options
  • Save jdecode/2e9a6665a21d32da8dd28bff2ef84726 to your computer and use it in GitHub Desktop.
Save jdecode/2e9a6665a21d32da8dd28bff2ef84726 to your computer and use it in GitHub Desktop.
DynamoDB data modelling for dapier/admino - first time DynamoDB/NoSQL, expect big and stupid mistakes

The more I watch Rick's sessions from 2017, 2018 and 2019, more confused I get - so I guess I'd write it down.

There are 3 core steps (some have more, I want to stick to 3) to create a decent model that works well:

  1. Understand the usecase + create ERD(list entities and relations)
  2. Identify the access patterns - R/W workloads, query dimensions and aggregations
  3. Data modeling - avoid relational patterns, use 1 table(if there aren't any "documents", 1 should be fine)
  4. R.R.R = Review > Repeat > Review (go on till it makes sense)
@jdecode
Copy link
Author

jdecode commented Aug 24, 2020

User will have many connections

User will have many permissions

Connection will have many permissions

@jdecode
Copy link
Author

jdecode commented Aug 24, 2020

From DynamoDB POV, the PK/SK structure would look something like this:

For "users":
PK = USER_{email-goes-here}
SK = TRUE or FALSE (depicting "active" status)
meta = JSON

For "connections"
PK = CONN_{ID-goes-here}
SK = TRUE or FALSE (depicting "active" status)
meta = JSON

For "permissions"
PK = PERM_{email-goes-here}
SK = {connection-ID-goes-here}
meta = JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment