Explain like I'm 5: Relation columns

Can someone please help me wrap my head around this? I’ve built tons of apps in Adalo and have used relational properties to associated data tables, but I just cannot understand this relation column.

My use case is super simple: A table of clients and a table of appointments. I want to link the two together so that I can do things like see the appointments for a specific client. I’ve watched the Glide videos but I don’t get it.

Please help, anyone…

Relations look for a matching value. When setting up a relation column, select the column that has a value that you want to check for. Then select the column in the other table that contains the exact same matching value. In your case, it could be a name, email, or some other kind of identifier. So when setting up a relation in your clients table, you want to link the client’s email, for example, to an email column in your appointments table. If the email for each individual row in the client table matches the email in any of the rows in the appointments table, then you have successfully created a relation. That relation in the client’s table is a link to all of the matching ROWS in the appointments table.

2 Likes

Assuming your client has an email address, or a unique ID, you would also include this piece of data with each appointment belonging to that client. Then you can make a relation from your clients table that gathers all appointments for each client, by matching the unique value from each client row, to all appointment rows containing that value.

4 Likes

I know when you first come across relations it can be hard to get your head around it.

When I was first learning I looked at the documentation :arrow_down:

This helped me a lot, especially when I read this

So basically have two match records in each table and then join them together using a relation

For example

Table 1
Column: Email
Data: test@test.com

Table 2
Column : Email
Data : test@test.com

The email in table 1 matches email in table 2 so I can now join these two tables together via the email column to create a relation. (I’m using email as a simple example it can also be any other data with matches in the tables)

Now you have built that relation you can use it to look up or through to the data and display it.

This helps with the look up of the data once the relation is created :arrow_down:

4 Likes

5 Likes

I am having a hard time explaining relations to people new on Glide, so it isn’t your problem!

2 Likes

Hi,

I’m going to simplify the two tables to make it easier to understand, but know that both can have more columns, and the result will be the same.

1 - In the clients table create a column “clients”;

2 – In the appointments table, create a column “clients” and another “appointments”;

3 – Add your list of clients in the “clients” column of table 1;

4 – So, when adding the appointments in table 2, it is necessary to indicate the clients, (if you are uploading the data with a form button, remember to insert this field in the form;

5 – Now, in table 1 create a relationship column, insert the clients name in the first field and in the second find table 2 and in the sequence also select clients (This creates a relationship between the two tables indicating that they have data linked to a same owner), also check the Match multiple box (as there may be more than one appointments for the same clients) and then click “DONE”;

6 – Ready your relationship is done, but you still need to bring the appointments data that are in table 2;

7 – In table 1 create a “LookUP” column, in the first field choose the relationship you just created and select which data from table 2 you want to use, in this case, the data from the “appointments” column then select it and then click on “DONE”;

8 – There, it’s done!!!

Now you can use this same relation in table 1 to bring any data from table 2 from a LookUP, or use the relation in “List Relation” or other rules;

2 Likes

Professional developers might cringe at my explanation. My apologies, but here goes.

Another way of seeing a relation column is a column in which you pull another sub-table. Once the sub-table is pulled into the relation column, you use a lookup column to fetch the column whose data you need in that sub-table.

If your relation is a single match (“match multiple” unchecked), then each cell in your relation column represents a single row of your sub-table. 1 cell = 1 row

If your relation is a multiple match (“match multiple” checked), then each cell in your relation column represents multiple rows of your sub-table. 1 cell = n rows = a full sub-table :exploding_head:. So each cell is potentially multiple rows down and columns across, even though it only appears as a cell.

In order to establish a link/match/relation between your two tables, you need one column in each table to hold the same data: same type (email, text, number, etc.) and same/matchable content. Imagine siamese twins. Your two tables need to overlap somehow to establish the link/match/relation.

Finally, practice first creating relations between distinct tables. Second and this can be trickier, create a relation of a table onto itself (different columns, or even the same column :nerd_face:).

4 Likes

Choose a key term in one table to match a search term in another.

If your relation is single it will stop the first time your key term matches your search term.

If your relation is multiple it will pull all matching search terms.

The next step typically is to use a lookup column with your relation as its source.

3 Likes

Single Relation:

What it is:
Matches a value in one column with the FIRST value found in a different column.

What it does:
Creates a one-row to one-row link between the two columns

What to do next: Display the relation using the Relation component or use a lookup column to grab a value from any column in the matching row.

Multiple Relation:

What it is:
Matches a value in one column with ALL values found in a different column.

What it does:
Creates a one-row to many-row link between the two columns

What to do next:

  • Display the multiple relation using an inline list component
  • Use a Rollup column to grab a count/sum/average/etc of numeric values of a column in all matching rows
  • Use a Join column to concaténate the values of a column in all matching rows

Example:

One table of users. One table containing user reviews. Each table has an email column.

User table:
Create a MULTIPLE relation column linking the email column in the users table to the email column in the user reviews table.

What this allows: on the user profile, create an inline list sourced by the relation that will display all reviews left by that user

User Reviews table:
Create a SINGLE relation column linking the email column in the user reviews table to the email column in the user table.

Create a lookup column that uses the single relation to find the user’s name from the users sheet.

Create additional lookup columns to find user photo or any other data found in the user table.

What this allows:
On a User Reviews screen, display the name and photo of the user that made the review.


Typically, you create relations between two different tables. Sometimes, you can use them to create a link within the same table, but this is usually an edge case.

9 Likes

After reading several explanations about what a relation is in Glide (something very similar working with most databases), I wonder now how Adalo carries out this? :face_with_head_bandage:

Saludos!

1 Like

Adalo make this so incredibly easy.

This is good feedback for the Glide Team. @JackVaughan @Mark @Jason @david

1 Like

HI hi

Just wondering if we can update Table 1’s columns via Table 2 Edit Form via Edit Form?

If there’s a relation, yes. On form submit, use a set column action and select the relation as the data source. Then you can update another table with the values of the submitted edit screen.