3 ms·
Ask HN: How does Twitter implement following and followers between users?
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?
- miguelrochefort 9y agoUser1 follows User2 User1 follows User3 User3 follows User1 User3 follows User5 ...
- bsvalley 9y ago--- 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.
- tedmiston 9y agoIn 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/introducing-flockdb.html https://blog.twitter.com/engineering/en_us/a/2010/introducin... [2]: https://github.com/twitter-archive/flockdb https://github.com/twitter-archive/flockdb