DEV Community

Discussion on: Data Modeling in Depth with GraphQL & AWS Amplify - 17 Data Access Patterns

ricardo1980 profile image
Ricardo Ruiz Lopez

Hello Nader,

Thanks a lot for your article, very interesting.
However, I don't know if I can do what I want to do using DynamoDB. It seems what I want is more complex. Can you review this?
Imagine I want to develop a dating app, when a user (entity) likes (relationship) another user (entity), is liked by another user, blocks another user, is blocked by another user, dislikes another user....
That kind of relationships may occur thousands of times, for example, you could like 10000 users.
Can I model that using DynamoDB? Using different tables I guess I can do it. But what I don't know is how to execute this request:

  • Get users that never blocked me, I never liked them, I never dislike them, I never blocked them. Close my area (I guess this is just testing longitude and attitude inside a range) and sorted by creation date (or any other field). Paginated.

Can I do that using DynamoDB or do I have to use Aurora? I know how to do that using SQL, but I don't know how to model this using DynamoDB (NoSQL) or even if it is possible.

Can I have your opinion about this?
Thanks a lot for suggestions.


codemochi profile image
Code Mochi

Hey Ricardo,
I'm obviously not Nader, but what if you created two tables "users" and "userLikes"? When someone clicks the like button, you create a new "userLike" document where you have a liker and a likee field? You could then easily do lookups based on the liker and likee, especially if you added them as one to many relationships on the "user" document. This would be the basic relationships:

user {
   admirers: [userLikes]
   crushes: [userLikes]

userLikes {
   liker: user
   likee: user
   isBlocked: boolean/string

You could add latitude/longitude and use the between that Nader mentions above and then use booleans for some of those other specifications such as blocked.