I have a data type ‘Podcasts’ that has hundreds of records (hundreds of podcasts) and is displayed on a card with the cover art, title, summary, etc.
Then I have a data type ‘Podcast Sponsors’ which is a list/table of sponsors specific to each podcast.
How do I display the unique number of sponsors a podcast has on the podcast card? I want users at a quick glance be able to see how many sponsors a podcast has before clicking into the actual podcast.
Well, you can store a list of the sponsors on each podcast, but that would cause some performance issues at scale, instead I would suggest just having a sponsor count number field and you update the number when there is a new sponsor etc
Podcast’s List of Sponsors:count should be fine. This is possibly the most performant way to do it, depending on what sponsors are. Is the point of your site that users can sponsor podcasts? If no (i.e sponsors are normally only a handful), this is fine. If yes, they’ll likely have hundreds and virtually limitless sponsors, so this method won’t work as the lists will become too large.
In that case, on the Podcast Sponsor data type, I would have a List of Podcasts. On the Podcast data type, have a count field. Add a backend trigger that watches the Podcast Sponsor data type’s List of Podcasts field. When a podcast is added/removed, modify the count by +1/-1 respectively.