Simple question about how to approach schema/collections

First things first, I’m a noob. Now that that’s out of the way…

I’m building a Podcast app utilizing MERN and some of the basic functionality I want on the back end is being able to “like” podcasts and perhaps create playlists.

All of the data for the actual podcasts is coming through via a 3rd party API so that’s not a worry.

So I’m trying to decide if I would create 2 collections?

  • users - login/logout
  • podcasts - likes, playlists, etc.

This is what I’ve seen from some of the courses I’ve taken, but it almost seems more sensible to just put those features in the User schema, no? That way I can just query the User and have everything right there.

I don’t understand a lot of the technical aspects of performance, but it just seems weird to store all of the likes by themselves, but also reference them to the user.

Am I thinking about this correctly? Or what would you do? Help is much appreciated!

Let’s look at it this way: If they were 2 separate collections, what would a document for each look like?

Yeah, I’m having trouble thinking of them as separate sort of. I guess you could just have a document for each podcast that was liked and then the users that liked it?

Idk. I’m leaning more towards embedding the likes into the user document. I’m just not sure if it’s bad practice to have to update the user document every time they like something?

Thank you for responding btw. I’m actually quite stuck on this even though it doesn’t seem like it should be all that hard.

The design problem you’re facing is simply an opportunity to think about design.

Do it both ways and play with it. What you learn will last you through your career.

1 Like

Fundamental principle of software design: Don’t rush to solve the problem … model various solutions. Find a model you like and grow it.

1 Like