# Composed\_of vs has\_one

**URL:** <https://www.ruby-forum.com/t/composed-of-vs-has-one/117015>\
**Category:** Rails\
**Created:** [October 12, 2007, 3:23am UTC](https://www.ruby-forum.com/t/composed-of-vs-has-one/117015 "2007-10-12T03:23:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericgoodwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@ericgoodwin](https://www.ruby-forum.com/u/ericgoodwin)\
**Post date:** [October 12, 2007, 3:23am UTC](https://www.ruby-forum.com/t/composed-of-vs-has-one/117015/1 "2007-10-12T03:23:05Z")

</div>

Im trying to decide how to model very simple relationships in  
ActiveRecord.

My understanding is that as far as database performance goes, using  
composed\_of will be easier on the database but a little ackward when  
working with the object, considering it the composed\_of object is frozen  
is not an AR class.

With a has\_one, you can include the object onto the main object using  
:include, where as, with a composed of relationship, you have to use the  
composed\_of name to get it initialized onto the object.

I guess the main question is, how much more efficient is it to have all  
the records already on the table, than to offload them to a has\_one  
relationship. To me it seems, like it greatly complicates the query  
required to retrieve the object.

In conclusion:  
has\_one: use when you rarely need to include it on the main object  
composed\_of: use this when you almost always need this object included  
with the main object.

Do you guys generally agree?
