I have a table Friendships with this fields:
|ID|Friend_owner_ID|freind_ID|
imagine that one of members of website sends a comment and I want inform all of his friends. so I would select all of friends of the member:
Select friend_id from Friendships where friend_owner_id=$comment_sender_id
and for each row I should:
insert into Notifications set reciever_ID=$friend_id, content='$content'
table of notifications would be like:
|id| reciever_ID| content |date|
and at last I must:
select content from notifications where reciever_id=$other_member
So if someone that has 5000 friends send a comment I should insert 5000 rows to the table wich does not seem to be wise and will consume so many resources.
Is there a better way?