views:

6

answers:

0

Hi everyone, im trying this concept of building a friend system for my application.I have some sucess in designing a database table for storing message a member updates in his profile.

This is the table model.


Message_id|Message|Message_Author

This is the table model to hold further message that belongs to a particular message.


Further_msg_id|Message_id|Further_Message|Further_Message_Author

This is the table that will hold all the friends for a member.


id|Friend_Profile_id|Accepted|Date_Added|

So, now, whenever a member add another member, i want to store that event into a table.I have made the table model like this.


event_id|event_message|event_owner_profile_id|event_type|

So, when A add B , then i want to add in the table as


1|A has added B |5|8

Now,the only thing that i can't get to work is how am i going to store the events that is happening between another two member. For example

A and B are two friends. Now A can have many friends. B will also have many friends too. Eg:- A--B (are friends) A--D (are friends) A--F (are friends)

B--Z (are friends) B--G (are friends) B--J (are friends)

How can i store events / retrieve events that is happening between B--Z,B--G,B--J into a table,so that A can easily acess it.

Or, is this the right way for retrieving events from friends of friends by simply pulling out the event column values from the events table that which belong to a member who is a direct friend?

A and B are direct friend. but B and D are not direct friend,however D again is a direct friend to A. Is there any good relationship method , which i can apply directly in order to get the events that is happening between two indirect friends.

Thanks in advance.

(My question is quite long,but i want to understand this concept and implementation from your suggestions and help)