8base users often reach out through our awesome Community for help with constructing and optimizing their Data Models. It not rare to see a developer having configured their data model like so:
You may be asking yourself, “what the heck am I looking at?” Well, data model Users are able to track who their BestFriends are, which happen to be other Users. To accomplish this, the developer set up a join table with User1 and User2 relationships to keep track of BestFriend records.
This would be the right approach…if 8base didn’t support self-referential relationships! This setup can be simplified to simply setting up a relationship from the Users table back to itself, like so:
This will greatly simplify your queries, mutations, and data model overall.