# Foreign key with 2 or more fields in a relationship

**URL:** <https://www.ruby-forum.com/t/foreign-key-with-2-or-more-fields-in-a-relationship/51918>\
**Category:** Rails\
**Created:** [January 9, 2006, 8:30am UTC](https://www.ruby-forum.com/t/foreign-key-with-2-or-more-fields-in-a-relationship/51918 "2006-01-09T08:30:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddiewould](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5e925/32.png) [@eddiewould](https://www.ruby-forum.com/u/eddiewould)\
**Post date:** [January 9, 2006, 8:30am UTC](https://www.ruby-forum.com/t/foreign-key-with-2-or-more-fields-in-a-relationship/51918/1 "2006-01-09T08:30:23Z")

</div>

In rails with a 1-M or M-M relationship you can use :foreign\_key =  
â??xxxxxâ? to override the default foreign key which will be used.

Is it possible and if so, how do you specify a foreign key for a  
relationship which has two or more fields in it?
