开发者

Friends table for a social network website

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

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

So for friends 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 friend request at that moment i made the both rows as active.

开发者_StackOverflow中文版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 suggestion regarding this please help me out to solve this asap.

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜