With Dynamodb do you guys tend to make real fields...
# random
t
With Dynamodb do you guys tend to make real fields for all properties in your data? Or do you have a general
data
map field that serves as a catch all and only pull out important properties
I've been doing the latter since it felt like unnecessary structuring but curious what others are doing
r
It depends, we spend a lot of time thinking about access patterns and try to think ahead to whether there are fields we think we may need to pull out into the keys of a GSI and those become the dedicated fields
t
That's been my approach too but I was looking at the documentation for https://github.com/sensedeep/dynamodb-onetable Might just be something they did for examples but they have a ton of fields where I would have just stashed most of those in a single
data
field
o
Almost never use maps, everything is top level - don’t get the purpose of putting the data inside a map?
t
^ I personally like nested data. For example instead of having
first_name
last_name
middle_name
display_name
I prefer doing
name = { first, middle, last, display}
Which is how I return the data in my domain objects so saves me some mapping
r
Yeah, it's certainly neater to work with but loses you flexibility in future as if you ever needed to access something based on name.last you'd have a data migation on your hands before you could implement the GSI
t
Don't you need to do a data migration anyway to move the data into the GSI field?
I have generic GSI columns (eg GSI1PK)
r
No, the index will be built from the existingfields you specify
t
Isn't there a limit on how many GSIs you can have? That's the reason I use generically named columns that get reused
r
You can have 20 GSIs and 5 LSIs
We use the generic PK and SK naming for the main table (guided by Alex Debrie's book) and will do for known GSI PK and SK too, if we know them upfront. However, if we find out down the line that we need to GSI on a non-generic field, we use it
t
gotcha makes sense
haven't yet had to retroactively add an index
o
Yeah I do both - use generic fields for GSIs I know I’ll probably need up front, but I’ve added GSIs after the fact
f
Yeah, haven’t done it myself, but knowing overloading GSI is the recommended approach 😁