views:

36

answers:

1

Hello,

Now i am working on a social network website and i already built the friends table for this website but i need some suggesion before i moved forward.

I have a user table where user_id is the primary field.

So for frinds i made a friends table with fields like

friend1,friend2,is_active

what i do actually when user1 send a friend request to user2 then at that moment i insert the two rows into the friends table like

1- friend1->user1,friend2->user2,inactive 2- friend1->user2,friend2->user1,inactive

So when somebody accept the frind request at that moment i made the both rows as active.

I made this two entries as i want whenever one user block another then easily made that corresponding row belongs to that user will be inactive.

And if a user remove the user then at that time i delete the both entries.

So please i need some suggesion regarding this plz help me out to solve this asap.

I need to know is there any other way which will be more optimised than this and giving proper result.

+1  A: 

I think that Friends_table with

User_id1, User_id2 and Rleationship_id

is easier, index on both first and second column. relationship id will be 1 - id1 request, 2- id2 request, 3 - friends, 4- id1 blocked, 5 - id2 blocked...

just an idea.

Dani
ya i got it and it seems more optimised than the one i mentioned neways thank you for you response.
pravat231
Yes you are absolutely correct this one is best and works perfectlly thank you Dani thanx a lot for helping me. One another question can you tell me what will the table fora message table like mail.
pravat231
more than one table probably, if you want to support distribution list, mail folder ect. you need to be more specific about what you want.
Dani
i don't need any mail folder i just want user send the message to another user and it shows in his inbox and stuff used in facebook messaging and also in some social network website not like gmail or hotmail..
pravat231