Hi! Iād love to explain. I didnāt get relations either at first.
Imagine youāre building a social media app - an Instagram app.
Users can
How do you make sure that each comment belongs to that post? How do you make sure it doesnāt belong to another post?
The answer?
Relations.
Letās talk about how to setup a relation - a relation needs a specific value to relate to - it needs for something to match a value in another sheet - or in the same sheet, if you prefer. That might sound confusing at first, but keep reading.
When a user writes a comment, it opens up a form, right? And that form is where they can add the text that the comment contains.
So hereās how to add a relation. First of all, add a new column to your āRepliesā worksheet. It should be called āPost replying toā. Next, add another text entry pointing to āPost replying toā that should only be visible when the post title is [garbage text]. Yes, I know the post title is never going to match whatever garbage text you inserted, but thatās the point! Youāll see why in a second - you donāt want to give the user the ability to edit the post itās replying to! Next, make the default value the title of the post. In summary, what you just did is make an entry invisible so that users canāt see or edit it.
Next, you want to set up your relation. Go to the Glide Data Editor, and click new column. Then, set the column type as āRelationā. Hereās the setup: Choose that the āReplying toā column matches the value in āPosts>Titleā. Do not select āMatch Multipleā.
You can now add a relation component to your reply layout, so that when clicked, it will bring you to the post itās replying to.
We did singular relations. Now letās focus on Multiple Relations.
For clarification: Singular Relations let you refer something to ONE value in another sheet. Multiple Relations lets you refer something to MANY values in another sheet. We just made it so that when a user clicks the relation component in the comment, it will bring them to the post. But now itās time for the most important thing. How do you list the Replies in your post? For that we need to refer something to MANY values in another sheet - thereās not going to be a maximum of 1 comment!
This part is easier, because you already did the singular relation before. Add a Relation in the GDE in the āPostsā sheet and Make is so that āPost Titleā refers to āComment replying toā in the Comments sheet. Donāt forget to make it a Multiple Relation by selecting that checkbox!
Now, what you can do is list the replies in your post - the source should be the relation.
I really hope this helped you a bit more. Also, are you just experimenting with Relations or just experimenting? If you still donāt get it Iād be glad to make a copyable app.
All my best!
Pablo