473,807 Members | 2,877 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store Friend relations

bilibytes
128 New Member
Hi,

i am trying to figure out how to store a friend relation beetween my users.

1.
I thought about using arrays, store for each user an array containing all its friends. But i don't know if arrays are suported in MySQL:
-> if they weren't i could also do a string which is the result of friends concatenation. But maybe it would be to much work to explode and implode the content at each time a user wants to get a list of its friends.


2.
then i thought about using a simple paired relation:
user1 is friend with user2 and the relation status: -1 for friends, -0 for friendship requested
so table would be:
Expand|Select|Wrap|Line Numbers
  1. user1 | user2 | status
  2. paul  | john  | 0
  3. paul  | ron   | 1
  4. jimi  | paul  | 1
  5.  
ok so when the user requests to be friend of an other one, i insert his name in "user1" and the requested friend in "user2"
Example:
paul asked john to be his friend. -> 0 ->friendship not confirmed yet
paul asked ron to be his friend-> 1 ->friendship confirmed, updated 0->1

This would work fine if:
before i insert a friendship request into the table, i look into "user1" coulumn.

Expand|Select|Wrap|Line Numbers
  1. if(there is a record of the requesting user into user1){
  2.      insert into coulumn user1
  3. }
  4. else{
  5.     insert into column 2
  6. }
this would prevent "friends" table from having the same user name(in fact: id) into the 2 different columns, as i have in the Table example above.
-> john is either on user1 and user2 columns.

THE Question is :
isn't that to much work to perform for a simple friend request insertion?

3.
the other possibility which extends this last one, is not to perform the check at insertion, but then check on select into the two columns:

Example, john wants to see his friends:

Expand|Select|Wrap|Line Numbers
  1. SELECT user1 and user2
  2. FROM friends
  3. WHERE user1 = john OR user2 = john 
  4.  
then i should reorder the resultng array..


Experts, what do you think i should do?

Thankyou very much

bilibytes
Nov 14 '08 #1
0 2617

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2992
by: Bose | last post by:
Hi I have to make export of SQL Server Database to MS Access and I have done it with the tables but now I need to transfer(export) the relations, keys and indexes. Can any1 tell me how to read relations,keys and indexes from SQL Server and convert them to MS Access.(it seams that for creation of indexes in MS Access ADOX is the only way but ADOX cannot read all information about keys,indexes from SQL Server.) All I can see is that I have...
2
945
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
1
1575
by: Iain | last post by:
I've a fairly complex schema which I'm trying to create a typed data set for. I've had a number of issues to date but it is sort of working (e.g. elements are not considered nullable unless minOccurs="0" is present. If not the codegen:nullValue attribute is ignored). What I'm seeing at the moment is that if I do NOT add in key and key ref relations, the cs generated puts in sensibly named relations with appropriate accessors. But...
1
1805
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because after running the code the relations don't show in the relations window. However when I enter data in an underlying table I get referential integrity error messages so the relations does actually exist. The created relations do show in the relations...
1
5132
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary" ds.Tables(2).TableName = "MaterialSummary" ds.Tables(3).TableName = "ItemUsage" ds.Tables(5).TableName = "UsageSummary"
2
2494
by: Joe | last post by:
Hi I am going to receive a dataset downstream and I will not know the the fields number of field relations number of relations So I have to be flexible to take unknown data and be able to summarize all the info being passed
5
3113
by: G .Net | last post by:
Hi I'm hoping that somebody can help me with a fairly puzzling problem. I've created some DataTables which have relations between them e.g. one to many. In the application, I want to remove entries from the table. To do this I obviously need to temporarily switch off the relations. In order to achieve this, I tried: ds.Relations.Clear() ' where ds is the application DataSet
1
1374
by: ramapriya92 | last post by:
friend : F - Few R - Relations I - In E - Earth N - Never D - Die %%%%%%%%%%%%%%%%%%%% http://padmagirl.blogspot.com %%%%%%%%%%%%%%%%%%%%%
3
1055
by: King | last post by:
This is a new test for object persistency. I am trying to store the relationship between instances externally. It's not working as expected. May be I am doing it in wrong way. Any suggestions? import shelve class attrib(object): pass
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.