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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:24:18+00:00 2026-05-29T08:24:18+00:00

+———————————–+ | fID | personA | personB | fStatus | |———————————–| | 1 |

  • 0
+-----------------------------------+
| fID | personA | personB | fStatus |
|-----------------------------------|
|  1  |  u1ID   |   u2ID  |    1    |
|  2  |  u3ID   |   u4ID  |    0    |
|  3  |  u1ID   |   u3ID  |    1    |
+-----------------------------------+

Status Column Codes:
0: Pending (personA wants to be friends with personB)
1: Friends (personA with personB)

* On removal request by either side > delete the corresponding row

I want to have a simple MySQL table by which I could implement a friendship option on my website. Being friends or not is all it needs to possess.

Now I want to know about the best approach for this purpose, and if there is something that I’m missing. I want to query friends of each user and users should be able to add or remove each other from their friend-list(s).

  • 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-29T08:24:19+00:00Added an answer on May 29, 2026 at 8:24 am

    Since each person could be friend with another person, you need to implement a NxM (many to many) relation. That translates, in a relational database managemen systemt, in another table, to make the “junction”, just as you did.

    http://weblogs.asp.net/zeeshanhirani/archive/2008/08/21/many-to-many-mappings-in-entity-framework.aspx

    In you example, maybe you may want to add a column to know who asked the friendship to who else.

    edit: I would maybe remove the fId column and create a composed primary key of the columns (foreign keys) personA and personB. This way it will be avoided by the db to have more than one request for the same persons, and also to avoid a situation where personA ask friendship to personB and personB, instead of just accepting it, asks friendship to personA, resulting in two records!

    edit2: you could use the status field to store the friendship request “owner”:

    0: pending, A asked to B
    1: pending, B asked to A
    2: friends
    

    edit3: don’t you need an expiration time (column request_date)? if a friendship request is not answered in, say, 3 months, then the request expires and it is deleted.

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

Sidebar

Related Questions

— or — Is there a difference between these? Is one better-supported than the
I'm using a DatePicker ( org.apache.wicket.extensions.yui.calendar.DatePicker — Javadoc ) in a form. The form
string formIdList = 8256, 8258, 8362, 8120, 8270, 8271, 8272, 8273, 8257, 8279, 8212,
So to start, I have an array of XML files. These files need to
I'm using some of Firefox's specially-defined values for cursor, in particular -moz-zoom-in -moz-zoom-out -moz-grab
Basically, is there a way to write a.children('.outer').children('.inner') without the intermediate selector? I can't
I recently ran against a very interesting site that expresses a very interesting idea
I'm creating a FORM with PHP for an intranet webpage. Another PHP script is
All of my code is on my SVN, but I want some of it
I'm trying to create a chrome extension and im doing this by parsing an

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.