Relation between table

Hi everybody,

I’m working on sport app.

My first table is the user table with the gender , level and counties informations ( the user can play in different county)

My seconde table, is the Game table, with the gender (man only, women only), the level expected and the adresse of the game ( housenumber, street, post code, city and county)

On Match table, i would like to have a column with all the users who match with the game.

I created a template in each tables with Gender,Level,County and made a relation between the two tables.
It’s work when the user have selected juste one county but if the user has selectionned more than 1 county the relation doesn’t work.

Exemple :
User A : Gender = Male, Level = Medium, County = Seine-Saint-Denis, Val d’oise
Game 1 : Gender Game = Male Only, level expected = Medium, County = Val d’oise

The User A matchs with the Game 1 but I don’t know how to do it in my data editor.

A game has multiple Users
A User can match with mutiple game

Then, i would like to have this relation columne with the id user in order to have the email adress .

Thanks for your help

What are the columns you have for this table?

How do you structure it on the front end? Do you let users input their info for the Users table, then show them the matching games?

1 Like

Hey,
On the first table, the user’s table, we have the following informations : gender, level, county (or counties)


The user fills this informations when he does the onboarding step

Then, on the seconde table, the game’s table, we have also gender (or both of them if its a mixed game), level(s) and one county


this one is filled when a user create a game.

Yes, I show to the user the matching games by using the filter data ( i dont know if it’s the best option) :
User gender is included in Game User
and
User level is Game User
and
County’s match is included in Counties’ User

I would like to have a column with all the email’s user, which match with a game.

Like this i will be able to send an email to this people in order to warning them, there is a game which matches with their preferences .

One problem I can see right away, is that you will have issues finding a match because you use Row Owners in your user table. When Row Owners is applied, only the rows that a user owns are downloaded to their device, so they will never be able to see or access another user’s row. If this is vital to matching user up, then this won’t work.

This largely would be pretty easy by creating a template column in each table that joins Gender, Level, and County…and then create a multiple relation linking the Games table to the User table using those templates, but the fact that a user can use multiple counties, and a Game can have multiple genders does make this more complicated.

I would need to think about this more, but I think you would have to first create arrays for your County column in the User table and the Gender column in the Games table. You can do that with a Split Text column. Then you would have to create 3 separate multiple relations to link each the gender, level and county to the user table (making sure to use the split text column instead of the comma delimited column). Then you would need three lookup columns that return the User ID from each relation. Then I think you would need to use a variety of glide plugins or javascript to find the User ID’s that exist in all three relations. Ultimately you would want to end up with an array of User ID’s that match all three criteria. Then you can use that to create a multiple relation to the user table and get a list of matching users.

3 Likes

Yeah, that is the same way I have done with complex filters in my recent apps.

I usually have a working table (which in this case is @Thel93210 's user profiles row), then create as many relations as I need for all the fields I want to have as a filter.

Return all rowIDs that match, then find the ones that exist in all “joined list” of rowIDs returned from relations, using JavaScript.

2 Likes

First of all, Thank you @Jeff_Hager and @ThinhDinh for your help !

I think I have understood your replies, I did the multiple relation columns

I’m stuck at this step :

Then I think you would need to use a variety of glide plugins or javascript to find the User ID’s that exist in all three relations.

I found this functionality, but I don’t know how to use it (I’m a no coder for real :sweat:)

This step will find which ID is in three columns rigth ?
Then I will do an array with the data on the Java script’s column ?

Just jumping in here…

Based on previous advice from Jeff & Thinh, I think your next steps should be:

  • Firstly, create 3 Joined List columns. Each of these should use one of the relations that you have created, targeting the RowID/UserID. Each will give you a comma separated list of UserIDs.
  • Now, create a JavaScript column, and use the following code:
var arr1 = p1.split(", ");
var arr2 = p2.split(", ");
var arr3 = p3.split(", ");
var data = [arr1, arr2, arr3];
var result = data.reduce((a, b) => a.filter(c => b.includes(c)));
return result.join(",");
  • In the JavaScript column, you use 3 replacements: p1, p2, p3. Each of those will be replaced with one of your Joined List columns. The JavaScript column will return a comma separated list of UserIDs representing those UserIDs that exist in all 3 lists.
  • To relate this back to your Users table, you would need to create a Split Text column that uses the JavaScript column as its source, and then you can use the Split Text column to create a relation with your users table.
3 Likes

Muito obrigado, xin cảm on, thank you @Darren_Murphy @ThinhDinh @Jeff_Hager

I think we’ve made it !

A lot of work to do but this step is done!

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.