This file describes how to create correct entities to implement requirement relations.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Many to many control
~~~~~~~~~~~~~~~~~~~~

To create correct M2M control you need to do the following steps:

To bind 2 entities A and B by multiselect control which points from A to B, you need 3 entities: A, B, A_to_B
Create entity A, B, A_to_B:

<entity name="a" dbobject="a_table" listfield="pkey">
<efield name="pkey" pkey="true" required="true"/>
<dataset name="b_multiselect" entity="a_to_b" linked-entity="b" control="m2m"/>
</entity>
---------------------
<entity name="b" dbobject="b_table" listfield="pkey">
<efield name="pkey" pkey="true" required="true"/>
</entity>
---------------------
<entity name="a_to_b" dbobject="a_to_b_table">
<efield name="a" pkey="true" required="true"/>
<efield name="b" pkey="true" required="true"/>
</entity>

This sample works correctly if a_to_b_table has foreign keys to a_table and b_table. If the a_to_b_table can't have foreign key to either a_table or b_table for some reason (for example b_table is view actually) you should add <fkey Å/> attribute to entity which contains <dataset Å/> attribute. Here is the sample, where a_to_b_table doesn't have foreign key to b_table: 

<entity name="b" dbobject="b_table" listfield="pkey">
<efield name="pkey" pkey="true" required="true"/>
<fkeys pkColumn="pkey" fkColumn="b" fkEntity="a_to_b"/>
</entity>

Note: Instead of fkEntity="a_to_b" you can write fkTable="a_to_b_table".