How is the application implemented, for example, twitter?

Suppose A is 100 people,

then 100 connection operators are required,

which is terrible for the database, I think.

Or are there other ways?

+3
source share
2 answers

Why do you need 100 pieces?

You will have a simple “Follows” table with your identifier and the identifier of other persons in it ...

Then you extract the “Tweets” by attaching something like this:

Select top 100 
    tweet.* 
from 
    tweet 
inner join 
    followers on follower.id = tweet.AuthorID 
where 
    followers.masterID = yourID

Now you just need decent caching and make sure you're using a non-blocking request and you have all the information ... (Well, maybe add some user data to the mix)

Edit:

tweet

ID - tweetid
AuthorID - ID of the poster

Lecture hall

MasterID - (Basically your ID)
FollowerID - (ID of the person following you)

Followers master followerID 2 - "masterID - followerID" "FollowerID MasterID"

+6

, (, , ) . Twitter , . Twitter: Twitter 10000 . , "", - ( ) don ' t . < - !

+1

Source: https://habr.com/ru/post/1717511/


All Articles