Jump to content

Hypothesizing on how FaceBook does there friends updates in the center collumn


TGWSE_GY

Recommended Posts

I am creating a Community Site and it intrigues me on how Face Book 1. Displays the status updates and other things that the user does in the center column. 2. How it refreshes on its own.

 

What I am wondering is 1. How do they achieve displaying all of the users friends updates. I know that it has to be stored in mysql/sql however I am trying to hypothesize on the php code behind the scenes.

 

I would imagine that one could make it really difficult on themselves with a lot of useless code or one could make easy on themselves through the use of recursion. I am really wondering what peoples thoughts on the process is because I have an Idea of how to achieve it, However all attempts to date fail in one form or another. I really have no code to show because this is less of a debugging question and more of a  "How Does It Work" question.

 

Any input would be great!

 

Thanks fellow PHPFREAKS! ;D8)

Link to comment
Share on other sites

1. Have some activity table keep track of what any given user is doing. Then query it.

2. AJAX to have it refresh on its own.

 

Though I admit I don't use Facebook nor do I like it so I have no further knowledge because I have no idea what Facebook does with the updates. I don't think you need recursion though. A SQL JOIN most likely.

Link to comment
Share on other sites

Hi

 

All threads seem to relate to a particular user, so they can just check that particular user is a friend. Doesn't care if any of the replies are from non friends.

 

Say they have a table of threads and a table of posts, a table of users and a table of users friends.

 

Threads

ThreadId

UserId (owner of thread)

 

Posts

PostId

ThreadId

UserId

 

Users

UserId

Name

 

UserFriends

UserFriendId

UserId

 

SELECT *
FROM Threads a
JOIN UserFriends b ON a.UserId = b.UserId AND b.UserId = $LoggedInUser
LEFT OUTER JOIN Posts c ON a.ThreadId = c.ThreadId
LEFT OUTER JOIN Users d ON c.UserId = d.UserId

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.