I have always been curious as to how twitter implemented this in their user model. How do they keep track of who the user is following and who is following the user?
Ask HN: How does Twitter implement following and followers between users?
1–4 of 4 posts
Re: Ask HN: How does Twitter implement following and followers between users?
#2User1 follows User2
User1 follows User3
User3 follows User1
User3 follows User5
...
Re: Ask HN: How does Twitter implement following and followers between users?
#3--- USER TABLE ---
| USER_ID |
| USERNAME |
| NB_FOLLOWERS |
| TWEETS -> List of TWEET_ID's |
| FOLLOWING -> List of USER_ID's |
| FOLLOWED_BY -> List of USER_ID's |
etc.
NB_FOLLOWERS, FOLLOWING and FOLLOWED_BY are updated when a USER follows/unfollows another USER.
Re: Ask HN: How does Twitter implement following and followers between users?
#4In 2010, Twitter was using a graph database, FlockDB, instead of a relational database to implement their social graph where relationships like following and followers are represented as edges between nodes that represent people.
It's since been deprecated, and I'm not sure what type of database they're using today. Anyway, they have a nice write-up blog post [1] and FlockDB is open source [2].
[1]: https://blog.twitter.com/engineering/en_us/a/2010/introducin...