Thanks to Richard Threlkeld and Attila Hajdrik for their help writing this article.
How to implement a real-world & comprehensive data model...
For further actions, you may consider blocking this person and/or reporting abuse
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:
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.
Ricardo.
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:
You could add latitude/longitude and use the
betweenthat Nader mentions above and then use booleans for some of those other specifications such as blocked.Thank you Nader this is a fantastic resource.
A bit late here in London, so I might be missing the obvious, but anyways here is a pedestrian question about item 14.
The same can be achieved by
listEmployees(filter: {jobTitle: {eq: "Manager"}})with the benefit of being able to use filter with other operators. So what is the benefit of your approach? Is is performance mainly?
thanks
Petros
So either can be used, but the query on index is preferred because a filter with scan will scan the entire database and then discard the items based on the filter, while the query will only query the items needed so the operation is less expensive in general.
Really good resource Nader.
What I find challenging is when I model my graphql schema, without Auth they work well, as soon as I add authentication, then I start getting problems with it. Mostly with many to many relationship with nested models.
Have you come across any of that? Would you be able to add this example and introduce auth to it?
Thanks
You can break the Many to Many Schema with a intermediate Table.
Example Group to Users
Model:
Also, just wondering does AWS Amplify charges link to DB Model Operation? Can't find it any place like how much is model we create how much data operation happens with the model.
-Regards
Alex
Nader,
I'm struggling a little on how you represent Order Line Items. In the original documentation it has a Order Line Items table to represent more than one product on the order. It would be fantastic if you could show how that would work in this context. Many Thanks.
guess that's a no
Hey !
Just wondering what will happen to existing data if the data model is changed?
-Regards
Alex