Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 525357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:39:47+00:00 2026-05-13T08:39:47+00:00

I have a social network similar to myspace/facebook. In my code you are either

  • 0

I have a social network similar to myspace/facebook. In my code you are either a person’s friend or not a friend, so I show all actions from people you are friends with (in this post I will refer to actions as bulletin posts alone to make it easier to visualize.

So you every time a person post a bulletin it will show up to any person who is there friend.

In mysql you would get a persons friend list by doing something like this,

SELECT user_id FROM friends WHERE friend_id = 1 (user ID)

I want to know how a site like facebook and some others would show all bulletin post from your friends and from your friends’ friends?

If anyone has an idea please show some code like what kind of mysql query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:39:48+00:00Added an answer on May 13, 2026 at 8:39 am

    The answer is that they aren’t doing selects on a friend table, they are most likely using a de-normalized news-event table. We implemented a news-feed similar to Facebooks on DoInk.com, here’s how we did it:

    There is the notion of a “NewsEvent” it has a type, an initiator (a user id) and a target user (also a user id). (You can also have additional column(s) for other properties relevant to the event, or join them in)

    When a user posts something on another users wall we generate an event like this:

    INSERT INTO events VALUES (wall_post_event, user1, user1)
    

    When viewing user1’s profile, you’d select for all events where user1 is either the initiator or the target. That is how you display the profile feed. (You can get fancy and filter out events depending on your privacy model. You may consider doing this in memory for performance reasons)

    Example:

    SELECT * FROM events WHERE initiator = user1 or target = user1 //to see their profile feed
    
    SELECT * FROM events WHERE initiator IN (your set of friend ids) //to see your newsfeed
    

    When you want to see the newsfeed for all events relative to your friends you might do a query selecting for all events where the initiator is in your set of friends.

    Avoid implementations with sub-selects, depending on the complexity, they will not scale.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a social network site similar in design to a myspace/facebook type community,
I have a social network similar to myspace but I use PHP and mysql,
In order to not show the ID's of the members of my social network
I have been rebuilding my social network in code igniter and am looking for
I am creating a social network and want to have a similar photo gallery
I have a social network type site (member site) I store a lot of
I have a jomsocial installation at http://social.drishtant.com/social-network-for-social-impact How can I embed the jomsocial component
I have chosen diploma work in university. It's a mini social network. But now
I am a PHP beginner. I have developed a social networking website similar to
I have an idea of a social network website and I will be working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.