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 132073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:12:19+00:00 2026-05-11T06:12:19+00:00

I am in dilemma, do not know which one is better. (I am using

  • 0

I am in dilemma, do not know which one is better. (I am using php and mysql btw)

Lets say I am developing a social community website. A user can add as many friends as he wants. In my database, I have a users table which store user’s details include user’s friends. Should I store the user’s friends in:

Strings => john;bryan;sam;paul;…;

or

Integers => 1;21;50;1779;30;…;

String means store their username. Integer means store their user id.

Which one is better?

If string, it would be a very, very large string(imagine the users have 400 friends, and some usernames are extreme long)

If id, how to list friends on user profile page? Getting list of IDs in one long string (separated by semicolon), use explode function to make it into array. Then using loops to display?? Isn’t troublesome? Is there any other way? If yes, please show some sample code..

OR normally, how would u guys to store the ‘friends’ list in the user table?

  • 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. 2026-05-11T06:12:19+00:00Added an answer on May 11, 2026 at 6:12 am

    Don’t store them as a semi-colon delimited anything. Store them as user IDs in a lookup table. Suppose the user is #2. You might have:

    SourceUserID | FriendUserID 2              1 2              21 2              50 2              1779 2              30 1              // One of John's friends 

    Then to display the list of friends, you query this table restricting it by SourceUserID = 2 and join against the user table to get the names. For example:

    SELECT Name FROM SITE_USERS INNER JOIN USER_FRIENDS ON SITE_USERS.ID = USER_FRIENDS.FriendUserID WHERE SourceUser = ? 

    (Or whatever your parameterised query format is; populate the parameter with the ID of the user whose page you’re displaying.)

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

Sidebar

Ask A Question

Stats

  • Questions 166k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer function daysInMonth(m, y) { // m is 0 indexed: 0-11… May 12, 2026 at 1:16 pm
  • Editorial Team
    Editorial Team added an answer That's a weird CSV. Since a comma-separated file is usually… May 12, 2026 at 1:16 pm
  • Editorial Team
    Editorial Team added an answer Here's the Jetty documentation page on how to use it's… May 12, 2026 at 1:16 pm

Related Questions

I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing
I have an SSIS package I am developing. I am attempting to write data
I was wondering what you do when developing a new application in terms of
I have an internal WPF client application that accesses a database. The application is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.