Reading Data | Convex Developer Hub

2) My team is asking about joins and best practices around data model normalization/denormalization. Are there any docs on best practices and on how Convex deals with joins etc? In the docs I find https://docs.convex.dev/database/reading-data#more-complex-queries and the last example looks super naive at first look, but I believe that's the idea, that Convex is converting it to a single query, and doesn't loop through it the way it looks. Yes?
3 Replies
Michal Srb
Michal Srb2y ago
That doc is right. You can implement the join in JavaScript/TypeScript. With Convex your backend function code runs close to the DB, so you don't need to worry about incurring large latency for repeated reads from the database. We might add a more dedicated syntax for joining data from multiple tables in the future. Let us know how if you encounter any challenges with our current approach!
jamwt
jamwt2y ago
@Mikael Lirbank also, more best practices guidance at these two links, including some tools for making joins easier with less boilerplate: https://stack.convex.dev/relationship-structures-let-s-talk-about-schemas and https://stack.convex.dev/functional-relationships-helpers
Relationship Structures: Let's Talk About Schemas
In this post we’ll look at some patterns for structuring relationships in the Convex database.
Functional Relationships: Helpers
In this post, we’ll look at some helper functions to help write code to traverse relationships in a readable, predictable, and debuggable way.
Mikael Lirbank
Mikael LirbankOP2y ago
Thanks guys! I'll read through those blog posts.

Did you find this page helpful?