How to handle special custom foregin key requirement in moqui entity definitions

74 views Asked by At

I have two entities defined as below:

<entity entity-name="e1" package-name="p">
  <field name="f1" type="id" is-pk="true"/>
  <field name="f2" type="id" is-pk="true"/>
  <field name="f3" type="text-medium" />
<entity/>
<entity entity-name="e2" package-name="p">
  <field name="f4" type="id" is-pk="true"/>
  <field name="f5" type="id" is-pk="true"/>
  <field name="f6" type="text-medium"/>
<entity/>

As seen in above definition, there are two(composite) primary-keys in both tables. Adding following relation

relationship type="one" related-entity-name="e2"

to e1 creates a relation with both the primary keys in other table. I don't want that. How do I create a foreign key realtionship so that: e1.f2 (single column) referes to only single column of the other table e2.f5 ? Please help.

1

There are 1 answers

0
David E. Jones On BEST ANSWER

What you are describing is a type "many" relationship, not a type "one" which would have a foreign key. This is a database constraint, not a Moqui one, but a foreign key must refer to the entire primary key of the related table.