Collections: Self Relations

What is the purpose of a Collection having a relationship to itself?

The purpose of a collection having a relationship to itself :point_down:

let’s say we have a social media app where users can follow other users. In this case, we have a “User” collection that contains information about each user, such as their name, email, and profile picture.
To model the relationship between users, we can create a self-referential relationship (Collection having a relationship to itself) between the User collection.

Each user has a “following” field that contains an array of references to other users. This array represents the users that the current user is following.

In the same way, each user also has a “followers” field that contains an array of references to other users. This array represents the users that are following the current user.

This way, we are able to use a single User collection to model both the followers and the following relationships, making it easy to understand and easy to implement.

Hope this helps. Feel free to reach out if you need any other assistance. Happy to help and brew interesting conversations
Linkedin: https://www.linkedin.com/in/sahira-mehta/

Sahira Mehta

1 Like

Construction App
So I have a collection of Contractors and I want a list of Contractors that they work with I would do this:

Collection: Contractors
Relationships:
M-Contractors to M-Contractors (My Contractors) for Contractors that I Subcontract for.
M-Contractors to M-Contractors (My Subs) for Contractors that Subcontract for me.
M-Contractors to M-Contractors (My Referrals) for Contractors that I refer to others.

1 Like

Yes!

Does this also allow you to create unlimited subcategories?

Hello, sure so you can create any relationships in the same collection and a great example of these kinds of relationships is when creating followers and following between users.

Thank you!

What I meant is - a filtering system…

Lets say I want to have an unplanned number of subcategories. In my case it’s services. All service categories will start with “Industry”, most will then go to “Specialty”, and then they can go as far as they need to, but will always end at a service or a list of services.

Examples:
Flooring > Hardwood Flooring > Installations > Unfinished Installations

Install unfinished hardwood Flooring (Glued Down).
Install unfinished hardwood Flooring (Nailed Down).
Install unfinished hardwood Flooring (Glued & Nailed Down).

VS.

Staircase > Installations > Stair Treads

Install single return tread (R Return).
Install single return tread (L Return).
Install double return tread.
Install boxed tread.

I would like to be able to make it where I have a virtually endless number of subcategories off of the original “Industry” category before getting to the “Services” Collection AND a way to display them.

1 Like

I believe this is possible and different approaches can be implemented.

So the answer to your question is Yes! it is possible

If you want any help implementing it…feel free to message me or email me at sahira.mehta2@hotmail.co.uk happy to help :v: