Quantcast
Channel: Active questions tagged feed - Stack Overflow
Viewing all articles
Browse latest Browse all 549

Feed timeline system using nosql database

$
0
0

I am implementing an ios social media app using swift and Firebase realtime database. I am building a feed timeline that's going to display all posts from the users the current user is following for a given time window.

Solution 1 -

Db tables: users, posts, user-posts, user-following

Upload:

  • Write post data to posts table
  • Write post id to user-posts table only under the id of the post creator

Fetch:

  • Fetch all user ids of the users the current user is following from user-following table
  • For each of these user ids-fetch all post ids from user-posts table for a given time window-THEN for each post id, fetch the corresponding data from the posts table

Solution 2 -

Db tables: users, posts, user-feed, user-followers

Upload:Write post data to posts tableFetch all user ids of the publisher’s followersFor each of these user ids, write the post id in user-feed table

Fetch:

  • Fetch all posts ids from the user-feed table for a given time window
  • For each post id, fetch corresponding data from posts table

I know solution 2 is better performance wise, but for a very large number of users and thus data, wouldn't it be way more expensive ? Also, do you know a better solution of doing this ?


Viewing all articles
Browse latest Browse all 549

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>