How to create N-N Relation ship link between two schemas on schema level of adobe classic campaign | Community
Skip to main content
LakshmiPravallika
Community Advisor
Community Advisor
September 7, 2022
Solved

How to create N-N Relation ship link between two schemas on schema level of adobe classic campaign

  • September 7, 2022
  • 1 reply
  • 2597 views

Hi Team,

We have a requirement of creating a N-N Relation between 2 schemas..but we can't able to get the right syntax to do it.

Can you please guide us to achieve this.

Regards,

Pravallika.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Shubham_Goyal__

Hi @lakshmipravallika ,

To create a many to many relationship between table's (schema's) in adobe campaign you need to create an relationship (intermediate) table where you can store the relationship.

A relationship table will be linked 1:N with each table and this will let you link two tables with cardinality N-N. 

The best example of such linking is between OOTB tables "Groups" (nms:group) and "Recipients" (nms:recipient) where "Recipient list contents" (nms:rcpGrpRel)  is the relationship table.

Source schema of the nms:rcpGrpRel table:

<srcSchema entitySchema="xtk:srcSchema" genAccessors="false" img="nms:rcpgroup.png"
           implements="xtk:persist" label="Recipient list contents" labelSingular="Recipient lists content"
           md5="B44333B9AA70F65A87AD3BE34FC9AC9B" name="rcpGrpRel" namespace="nms"
           xtkschema="xtk:srcSchema">
  <element img="nms:rcpgroup.png" name="rcpGrpRel" pkgStatus="never">

    <!-- The index starts by iGroupId since we execute often SELECT iRecipientId ... WHERE iGroupId= -->
    <key internal="true" name="id">
      <keyfield xlink="rcpGroup"/>
      <keyfield xlink="recipient"/>
    </key>

    <dbindex name="recipientId">
      <keyfield xpath="@recipient-id"/>
    </dbindex>

    <element integrity="neutral" label="Recipient" name="recipient" revDesc="Lists to which the recipient belongs"
             revIntegrity="own" revLabel="Lists" target="nms:recipient" type="link"/>
    <element integrity="neutral" label="List" name="rcpGroup" revDesc="Recipients in the list"
             revIntegrity="own" revLabel="Recipients" revLink="rcpGrpRel" target="nms:group"
             type="link">
      <join xpath-dst="@id" xpath-src="@group-id"/>
    </element>
    <attribute label="Foreign key of link 'List' (field 'id')" name="group-id" type="long"/>
  </element>

</srcSchema>


Br,
Shubham


 

1 reply

Shubham_Goyal__
Shubham_Goyal__Accepted solution
Level 6
September 9, 2022

Hi @lakshmipravallika ,

To create a many to many relationship between table's (schema's) in adobe campaign you need to create an relationship (intermediate) table where you can store the relationship.

A relationship table will be linked 1:N with each table and this will let you link two tables with cardinality N-N. 

The best example of such linking is between OOTB tables "Groups" (nms:group) and "Recipients" (nms:recipient) where "Recipient list contents" (nms:rcpGrpRel)  is the relationship table.

Source schema of the nms:rcpGrpRel table:

<srcSchema entitySchema="xtk:srcSchema" genAccessors="false" img="nms:rcpgroup.png"
           implements="xtk:persist" label="Recipient list contents" labelSingular="Recipient lists content"
           md5="B44333B9AA70F65A87AD3BE34FC9AC9B" name="rcpGrpRel" namespace="nms"
           xtkschema="xtk:srcSchema">
  <element img="nms:rcpgroup.png" name="rcpGrpRel" pkgStatus="never">

    <!-- The index starts by iGroupId since we execute often SELECT iRecipientId ... WHERE iGroupId= -->
    <key internal="true" name="id">
      <keyfield xlink="rcpGroup"/>
      <keyfield xlink="recipient"/>
    </key>

    <dbindex name="recipientId">
      <keyfield xpath="@recipient-id"/>
    </dbindex>

    <element integrity="neutral" label="Recipient" name="recipient" revDesc="Lists to which the recipient belongs"
             revIntegrity="own" revLabel="Lists" target="nms:recipient" type="link"/>
    <element integrity="neutral" label="List" name="rcpGroup" revDesc="Recipients in the list"
             revIntegrity="own" revLabel="Recipients" revLink="rcpGrpRel" target="nms:group"
             type="link">
      <join xpath-dst="@id" xpath-src="@group-id"/>
    </element>
    <attribute label="Foreign key of link 'List' (field 'id')" name="group-id" type="long"/>
  </element>

</srcSchema>


Br,
Shubham


 

LakshmiPravallika
Community Advisor
Community Advisor
February 14, 2023

Hi Subham,

 

I didn't understand one Part in the N-N Link actually.

 

How is the column below getting populated to make the N-N Link work?

 

    <attribute label="Foreign key of link 'List' (field 'id')" name="group-id" type="long"/>

 

Could you Please let me know?

 

Regards,

Pravallika.