- Newest
- Most votes
- Most comments
You wouldn't store the personal user data in reviews, it doesn't make sense to do that.
PK | SK | userName | dateOfBith | ReviewerName | reviewerDatOfBirth | reviewDate |
---|---|---|---|---|---|---|
USER-123 | USER-123 | tempname | 09-09-2022 | |||
USER-123 | REVIEW-45 | 2023-01-01 |
Now you have 1 item containing user's information. If you want all reviews and user information in a single request, do this:
SELECT * FROM mytable WHERE PK = 'USER-123'
If you want only reviews:
SELECT * FROM mytable WHERE PK = 'USER-123' AND SK begins_with('REVIEW')
And if you want only the user info:
SELECT * FROM mytable WHERE PK = 'USER-123' AND SK = 'USER-123'
So according to you i dont need to store user info in reviews enitity. but how i am going to know who had created this review. let's just say user created a post and other users review on that post and i want to get all post reviews. by providing post id i can retrive all reviews but how do i know who had review on this post
|PK | SK | userName | profileImage | reviewDate |review| postDate | postDescription | reviewerId | | --- | --- | --- | --- | --- | --- | |USER-123 | dummyName |https://example.com | | | | | | |USER-123 |POST-123 | | | | | 2020/09/09| good day| | |USER-444 | dummyName2 |https://example.com | | | | | | | |USER-555 | dummyName3 |https://example.com | | | | | | | |POST-123 |REVIEW-23 | | |2021/09/09 |hello world | USER-444 | | | |POST-123 |REVIEW-44 | | |2021/09/09 |hello world | USER-555 | | |
So accroding to above example a user can create post and other user make reviews on it. USER-123 make a post with id POST-123 and other users review the post. if i want get all post reviews i can simple provide post key to all all post like
SELECT * FROM mytable WHERE PK = 'POST-123' AND SK begins_with('REVIEW')
by this command i can have all reviews but the question is who would i know user info who had make this reviews. According to you i dont have to store user info on reviews.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago