TGWSE_GY Posted June 4, 2009 Share Posted June 4, 2009 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! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 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. Quote Link to comment Share on other sites More sharing options...
otuatail Posted June 4, 2009 Share Posted June 4, 2009 You would use <div> 's and set positions for them. Then just place the content in them. Desmond. Quote Link to comment Share on other sites More sharing options...
Adam Posted June 4, 2009 Share Posted June 4, 2009 You would use <div> 's and set positions for them. Then just place the content in them. Desmond. I don't thik he was asking for the HTML side of things... Quote Link to comment Share on other sites More sharing options...
kickstart Posted June 4, 2009 Share Posted June 4, 2009 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 Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted June 4, 2009 Share Posted June 4, 2009 put an index on the activity table to make it quick and return it as json Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 4, 2009 Share Posted June 4, 2009 Do some research. Google is your friend. No. Joins and indexs will not help you optimize for 2 million users facebook has. A completely denormalized table is best. Quote Link to comment Share on other sites More sharing options...
TGWSE_GY Posted June 5, 2009 Author Share Posted June 5, 2009 Hi guys, thank you so much for the input. I have some good ideas from all of your input. I will leave this post up and be sure to share my final product with all of you. Thanks Again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.