I created a meditation app: there are programmes, each of them has a list of songs. When a user listens to a song, I keep the information in the DB (same for programmes). For that, I linked both collections: a user can have many songs and a song can have many users (same for programmes: a user can have many programmes and a programme can have many users)
I was wondering if the performance of the app could be really impacted if I have thousands of users (each song could have thousands of users and each user could have dozens of songs; same for programmes)
The performance of the app will be impacted with the growth of userbase and number of relationships between users and songs.
Real-life example from one of my clientsā apps: approx. 1K users and 150 businesses, each user can favourite a business, on average one user favourites ~10-15 businesses. I canāt count the total of number of relationships now, but adding a new one takes several seconds (so users simply donāt add new businesses as favourites - they donāt want to wait several seconds).
In some cases creating a separate ājunction tableā (each record has a link to a song, and another link to a user) could help, but the efficiency will depend on how are you structuring your screens and data access/ change in your app. And this, in turn, depends on the requirement why do you want to store the listened songs.
Couple of examples. If you would like to āfavouriteā a song directly from the song list, it will work badly both for M2M and for Junction table cases. If you limit the actions to a screen with a current song, then it might work better for some time.
Maybe you could use both approaches. As an idea - show M2M relationships in a song list (with NO actions); and use junction table in Song Details. Using Junction table to show the list of listened songs should work faster than filtering all songs using M2M (though I might be wrong here - I donāt know what optimizations does Adalo have under the hood).
Bottom line - I havenāt found any good solution using Adalo internal collections for creating favourites (Iām talking about scalable one). Maybe someone could advice. I have some promising results with external collections, though they are not yet ready to be published.
Thank you Victor for your really interesting feedback!
I am going to remove right away my āAdd a favouriteā feature, because the UX wonāt be satisfying like you said
But I was thinking about keeping the āUser can see the listened songsā feature. You said with your client it would take (with 1k users) several seconds to add a favourite, but does it take that long too to check the favouritesā list? or is it faster?
About your scalable solution you are testing with external collections, do you use Airtable, Spreadsheet or another solution?
Hi @Victor,
Do you find with join tables it is easy to have double / triple entries if the user clicks the button a few times? Sometimes I prefer a many to many setup so this is prevented.
I think that without a true 1:1 relationship option in Adalo, join tables can be problematic. BUT Iām happy to learn otherwise.
If you display songs in a list, I guess you will have to use M2M relationships to display ālistenedā songs. With junction table option it might be more resource consuming (for each song you will have to send a separate query to another table; 10 songs ā 10 queries).
If you mark the song as ālistenedā automatically (say, upon entering player screen with current song), and if you wonāt display all songs in one long list but rather in a ālazy loadingā one, then displaying ālistened songā label using M2M might work. Most probably Adalo will send a filtered internal query to its backend, and backend should (hopefully) do the job for you.
It will be slower, but I donāt know how much slower.
Reg. external collections - Iām not ready to disclose any info publicly yet, sorry.
Thank you Victor for your reply, indeed I use M2M relationships and I will display the list of songs and the listened songs will have an icon, so itās not that bad if the icon is displayed with a few seconds late
Youāre right, with M2M you wonāt get multiple entries by design.
For new records, unfortunately there is no efficient way (or at least way Iām aware of) to prevent Adalo from creating several entries by clicking button several times; it takes time to receive reply and process it, and user can click another time meanwhile. Sometimes combinations of junction and M2M may work.
As for Join tables - with relationships we get āsimulatedā join (in my opinion 1:M relationship could be viewed as a foreign key on M side). But of course we donāt get all the power of true SQL database. Keep in mind - this is a no-code platform