Hi all! Anyone able to give some DynamoDB advice t...
# random
m
Hi all! Anyone able to give some DynamoDB advice to someone very fresh to the NoSQL world? Maybe there's a good resource you can point me to. I've looked at dynamodbguide and watched some videos but I'm still not grokking it I'm creating a site that has: • User profiles • Users create talent trees (think this) • Users vote on "leaves" within those talent trees My thinking to implement the DB is: • PK: USER#name • SK: ◦ PROFILE#name ◦ TREE#id Attributes for the TREE#id item would be name, createdAt etc, but this leaves me with the following questions: 1. how should I go about storing the tree hierarchy itself (json stored within the TREE#id?) 2. where should the votes be stored? Directly on the tree? 3. down the line i'd like to be able to have users revisit an old tree and see what they voted for... does this change the implementation?
I think the answer to #1 is to have a TREE#id attribute be a series of nested maps
a
good orm for dynamo https://dynamoosejs.com/
I’m using it
m
Cheers, I'll take a look 🙂 I've mocked up the structure in sheets to try and convey it...
Does something like this make sense? Just to tick off question 1. Or should TreeItems actually be a a bunch of items (which I'd call nodes or similar)?
r
The DynamoDB book by Alex Debrie is excellent
s
Seconded. In my opinion, Alex consistently puts out the best DDB content available
@Matt Stibbard your data model will be determined by your applications access patterns. How do you plan to fetch and use this data? For example, do you need to fetch users by ID? Maybe fetch trees for each user? Do you need to update or sort by votes? The answers to all these questions will determine what your data model looks like.
According to your screenshot, your data model currently supports: 1. fetch user profile by username 2. fetch Tree by username 3. fetch Tree by username and tree ID If that's all your application needs, i guess you're done!
m
Thanks! I think I need: 1. Fetch user profile by username 2. Fetch trees by username 3. Fetch tree by tree id 4. Submit vote on leaf of tree 5. Fetch tree by tree id with my votes I guess the confusing bit is the voting mechanism...