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

  • SEARCH
  • Home
  • 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 3690702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:03:54+00:00 2026-05-19T04:03:54+00:00

I was wondering what the easiest method would be for me in the future

  • 0

I was wondering what the easiest method would be for me in the future to make queries both effective and less complex.

Should I save a two way relationship like

from_id=1, to_id=2
from_id=2, to_id=1

or just create one unique row

from_id=1, to_id=2

any thoughts?

  • 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-19T04:03:54+00:00Added an answer on May 19, 2026 at 4:03 am

    I would suggest to go for two way relationship. It’s flexible ans it’s only extra work while inserting and deleteing the records.

    The benefits that I see is:

    • To get all friend of a person all you need to do is where from_id=userid instead of where from_id=userid or to_id=userid that later is expensive.
    • you can keep extra metadata in forward and reverse relationship. Let’s say you have a case like userA is friend of userB while userB does not approves the relationship. To do this you may have an extra isApproved and set it true for from_id=userA, to_id=userB and false for from_id=userB, to_id=userA — this will allow further cheap sort and select.

      The effect in single row will be a little trickier.

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

Sidebar

Related Questions

I was wondering which method is the easiest or smartest way of making a
I'm wondering what the easiest (and most resource friendly) way would be to transform
I was wondering what the easiest way to parse/interpret a custom language would be.
I was wondering what would be the easiest way to update a column by
I was wondering what the easiest way is to convert an integer to the
I'm wondering what is the easiest way to persist a string value, once the
Just wondering what the easiest way to connect 2 jsp pages together, I have
I was wondering what the easiest way to write a simple form program or
I was wondering what is the easiest way to change the height of a
I was wondering what the quickest, easiest and most efficient way of running some

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.