Initialize users with many relationships

Hello,

I have a collection of users and a collection of videos.
I have 2 relationships many to many between users and videos (videos watched and videos favorite).

When a user signup I want to create the users with already:
2 videos watched and let’s say 2 videos favorite.

You can have automatic field, but not automatic relationships.

Thanks.

Hi @Nirvana,

You can do this with some workarounds. I would suggest using API call to create these relationships.
Another way is to use single-item list(s) to make video(s) available and assign them with some button/action inside these lists. But it’s not very optimal in my opinion.

Please keep in mind that many-to-many relationships will start working slowly with the growing number of users & videos.

Best,
Victor.

Hi @Victor,

Thank you.
I never worked with API, do you have an example (video or link) to use for these relationship ?

When do you think it will be slow ? Let’s say 10k users and 200 videos. Is it “a lot” for Adalo ?

Is there any other way to create the “watched video” part without many-to-many relationship ?

Hi @Nirvana,

Ok, let’s calculate: 10,000 users and 200 videos. For example, each user watches 20 videos and likes 10 videos. This will lead to 200,000 “watched” relationships and 100,000 “liked” relationships, and an average video will have 1000 “watched” and 500 “liked” relations.

In my personal opinion, this won’t work in Adalo using M2M relationships.

I would create a separate “Watched” and "Liked’ collections, linking videos and users, and add records there (sometimes this is called “junction tables”). These collections will grow in size very quickly, but as most of the time the data will be just added to these collections, with careful planning such approach will work for a longer time.

But if the figures you’re telling are real, I’d advice to use external collection DB with a proper query filtering - something like Supabase or Xano.

Best regards, Victor.

P.S. Several videos about “Junction tables” which might be useful for you:

Thank you @Victor for this long and perfect answer.

1 Like

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