Best practice for counting streams

Im building podcast app and I've question what is the best solution for counting streams? in postgres database should I just save array of people who streamed?
{
userId: String,
streamedAt: Date
}
{
userId: String,
streamedAt: Date
}
that comes in my mind as solution and is there any better way? (also that content must has analytics, dashboard and etc)
5 Replies
niko
nikoOP10mo ago
anyone?
benten
benten10mo ago
you should store it in base 3
niko
nikoOP10mo ago
what is base 3?
Shiny
Shiny10mo ago
I would store the watched podcast on the user. Then if a user streams a podcast check if they did before by accessing their history and if not increment a streams counter on the podcast object. Probably not the best solution but it reduces database queries compared to your solution I would save the history with an array of podcast ids on the user
Josh
Josh10mo ago
this is one of those times where denormalizing your db is reasonable
Want results from more Discord servers?
Add your server