educative.io

Educative

Why do we need FeedMedia table?

I understand we need a userFollow table as we may have a many-to-many relationship between user and entity
But why do we need a feedMedia table? Do we also have a many-to-many relationship between feedItem and media? Do we assume a feed can have multiple medias?

Hi,

Thank you for reaching out to us!
We are looking into the question you have asked, and will get back to you shortly.

The feedMedia tables primary job is to map any media to that feed (post). So lets say you post a photo on your feed, rather than storing the data as generic “content,” you would create a media object and associate your feed(post) item with that media object in the feedMedia table. So per feedItem, you will have 1 mediaItem if there is one. Also imagine, you upload 10 photos or an album, then in that case your feedItem will have many media objects.

Hope this makes sense.

2 Likes

If one media item belongs to only one feed item, can’t we simply store feed Item Id in media table and avoid FeedMedia table? This is similar to FeedItem having UseId (which helps to locate all feed items for a given user) as index. If we need many-many relationship then FeedMedia table might make sense.

I guess it needs to add more columns into FeedMedia table. Because if we try to use unique photos/or media then we need to have some specific file media metadata. For example: location_from, uploaded_date etc. If we want to have duplicate media - I agree we can avoid FeedMedia table