Hello there, I have an app where a user can browse and add places to its favorites. This User can have friends. I want to have the feature to recommend a place to a friend.
I have 3 tables : Users (with a isFriend boolean), Places and isFavorite which contains User + places info and allows me to register all the favorite places for a given user.
From the Favorites screen, I’d like to open a form which displays the user friends and then store the infos in another table : Current user, Friends and Place so I can use this to display a notification panel for each user with their friends recommendations.
I can’t figure out a way to do this. Either the form displays User informations and I can’t get the place info or I have to use the Notification table but don’t have the info neither.
Could I have some help with this please?
I recommend structuring the tables as follows:
Suggested Table Structures
- Users Table
- Columns:
- Relationships:
- One-to-Many:
Friends
- One-to-Many:
Favorite Places
Example:
- Friends Table
Example:
- Places Table
Example:
Place ID |
Place Name |
1 |
Central Park |
2 |
Eiffel Tower |
- Favorite Places Table
Example:
- Recommendations Table
- Columns:
User Email
(person recommending)
Place ID
Friend Email
(person being recommended to)
Example:
-
With this structure you can allow a user to select favorite places using the Favorite Places
column on the Users
Table by adding collection element for the Favorite Places
.
-
Then in the same collection element add item action to recommend a place to a friend, which when clicked should show a form to select a friend using the Friends
Column. The form should add a row to the Recommendations
table.
-
You can either use the Recommendations
table directly on the UI to show places recommendations, better yet create another one-to-many relationship column on the Users
table to Recommendations
table and then use it.
BTW: I used numbers for the ID columns for simplicity, but I would recommend using Glide’s Row ID instead. Also, you either need to filter the related tables to show only the records related to current user or better yet use Glide’s Row Owner
feature to make them private to each user. That way you don’t to worry about accidentally showing another person’s data on the UI.
2 Likes
Thank you @ raajkumars for your time and help.
Sadly, this doesn’t answer to my problem because when I show a new screen (from n action on a Favorite place) with the Friends table to select a friend to which I want to send a recommendations, I then can only operate with the data from Friends and I’m no longer able to fetch the data from the favorite place I clicked on.
And if I add a relation to Friends in Favorite Places, as a user can have many friends, I can’t show the list in a collection in my layout…
This is the main problem I encounter.
As you can see I did a relation with the user friends in the data, but I’m unable to use this in the layout part.
You need to set the Source of the collection as the relation. You are trying to set the Title to the relation which doesn’t make sense because a relation is a link to entire rows of data. Not a specific column or value in those related rows.
1 Like
But if I set the source to the Friends table, then I loose the ability to add the Place ID in my new Recommendation row 