# Has\_many (but parent & child should be same table )

**URL:** <https://www.ruby-forum.com/t/has-many-but-parent-child-should-be-same-table/153813>\
**Category:** Rails\
**Created:** [November 21, 2008, 11:54am UTC](https://www.ruby-forum.com/t/has-many-but-parent-child-should-be-same-table/153813 "2008-11-21T11:54:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 21, 2008, 11:54am UTC](https://www.ruby-forum.com/t/has-many-but-parent-child-should-be-same-table/153813/1 "2008-11-21T11:54:17Z")

</div>

i have user table  
each user have lots of friends  
how to design ?  
act\_as\_tree , will it work ?

any other suggestion appreciated.

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 21, 2008, 8:36pm UTC](https://www.ruby-forum.com/t/has-many-but-parent-child-should-be-same-table/153813/2 "2008-11-21T20:36:43Z")

</div>

> i have user table  
> each user have lots of friends  
> how to design ?  
> act\_as\_tree , will it work ?

You could, but it would be messy since you and I could be friends so  
who has many?

Start here:

[http://agilewebdevelopment.com/plugins/search?search=friends](http://agilewebdevelopment.com/plugins/search?search=friends)

Find one that only requires a _single_ row in the database to indicate  
you and I are friends as opposed to “Philip is a friend of Thani”  
_and_ “Thani is a friend of Philip”.

Last time I did this I used  
[http://agilewebdevelopment.com/plugins/has\_many\_friends](http://agilewebdevelopment.com/plugins/has_many_friends)  
. Worked well for me.

-philip

---

<div class="post-metadata">

**Author:** ![thaniyarasu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@thaniyarasu](https://www.ruby-forum.com/u/thaniyarasu)\
**Post date:** [November 24, 2008, 4:44am UTC](https://www.ruby-forum.com/t/has-many-but-parent-child-should-be-same-table/153813/3 "2008-11-24T04:44:34Z")

</div>

Philip H. wrote:

> [http://agilewebdevelopment.com/plugins/search?search=friends](http://agilewebdevelopment.com/plugins/search?search=friends)
> 
> Find one that only requires a _single_ row in the database to indicate  
> you and I are friends as opposed to “Philip is a friend of Thani”  
> _and_ “Thani is a friend of Philip”.
> 
> Last time I did this I used  
> [http://agilewebdevelopment.com/plugins/has\_many\_friends](http://agilewebdevelopment.com/plugins/has_many_friends)  
> . Worked well for me.
> 
> -philip  
> Thanks
