I have a couple of tables that relate to each other in a couple of different ways in my model, a table for fund requests that will both refer to the Entity table for a client and an employer - so it needs 2 indexes, what is the correct way to set up the XML model schema?
Here are the tables [drastically shortened!]:
<object class="FundRequest" table="fund_request" extends="xPDOSimpleObject">
<field key="token" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="unixtime" dbtype="varchar" precision="50" phptype="string" null="true" />
<field ... a bunch of fields not related to the question... />
<field key="payee_uid" dbtype="int" precision="8" phptype="integer" null="true" />
<field key="client_uid" dbtype="int" precision="8" phptype="integer" null="false" />
<aggregate alias="Entities" class="Entities" local="payee_uid" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Entities" class="Entities" local="client_uid" foreign="id" cardinality="one" owner="foreign" />
</object>
<object class="Entities" table="entities" extends="xPDOSimpleObject">
<field key="token" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="unixtime" dbtype="varchar" precision="50" phptype="string" null="true" />
<field ... a bunch of fields not related to the question... />
<aggregate alias="FundRequest" class="FundRequest" foreign="payee_uid" local="id" cardinality="one" owner="local" />
<aggregate alias="FundRequest" class="FundRequest" foreign="client_uid" local="id" cardinality="one" owner="local" />
</object>
I'm thinking I should be naming my aggregate aliases in the FundRequest tables as:
<aggregate alias="PayeeEntity" class="Entities" local="payee_uid" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="ClientEntity" class="Entities" local="client_uid" foreign="id" cardinality="one" owner="foreign" />
So I can refer to them as
$object->FundRequest->PayeeEntity->get('whatever');
in my code.
A) Is this correct?
B) How Should I label my aliases in the Entities table?
C) I think the alias types are correct, neither record in either table should get deleted if the other is removed.