Can I use the same foreign key for a manytoone and a onetomany?

The simple answer, is no.

You can only create one relationship per foreign key in your database, otherwise, this can cause infinite loops and Stack Overflows in Transfer.

For example, this would be configuration that could cause a Stack overflow:

<object name="Foo">
   ...
   <manytoone name="Child">
      <link column="BarID" to="Bar" />
   </manytoone>
</object>

<object name="Bar">
   ...
   <onetomany name="Parent">
      <link column="BarID" to="Bar" />
   </onetomany>
</object>

For some help deciding the difference, read What is the difference between ManyToOne and OneToMany?

Categories: