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