1 Answer
- Newest
- Most votes
- Most comments
1
Its a pretty simple data model, one table to hold comments and replies for all posts:
PK | SK | Data |
---|---|---|
POST#123 | COMMENT#001 | some comment |
POST#123 | COMMENT#001#REPLY#001 | some reply to comment 001 |
POST#123 | COMMENT#001#REPLY#002 | some reply to comment 001's reply 001 |
POST#123 | COMMENT#002 | some comment |
POST#123 | COMMENT#003 | some comment |
POST#123 | COMMENT#003#REPLY#001 | some reply to comment 003 |
POST#334 | COMMENT#001 | some comment |
POST#334 | COMMENT#001#REPLY#001 | some reply to comment 001 |
POST#920 | COMMENT#001 | some comment |
Here I have shown with incrementing numbers, which is likely not practical, I would suggest using ULIDs as part of the sort key, that will give you unique ID's which are time sortable so you can render a posts comments and replies in the order they were received.
Now to get all the comments and replies for a post its as simple as:
SELECT * FROM commentsTable WHERE PK = 'POST#123'
This is both scalable and highly efficient.
Relevant content
- Accepted Answerasked 8 months ago
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 14 days ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago