Scenario 5: Modelling the Buyer to Sales transaction relationship | Community
Skip to main content
Linda_Stinson
Adobe Employee
Adobe Employee
June 20, 2014
Solved

Scenario 5: Modelling the Buyer to Sales transaction relationship

  • June 20, 2014
  • 2 replies
  • 1468 views

Using what you have learned, how would you model the relationship between a buyer and their sales transactions? What would you add and to what schema? What would be the impact on the underlying tables?

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 Linda_Stinson

Keeping in mind that every order has a single buyer, but every buyer (Recipient) can have multiple orders, you would define the link in the order schema.  Most relationships are 1:1 in one direction and 1:M in the reverse direction.  You define the link in the 1:1 "direction". This has been done with neo:order.

    <element label="buyer" name="buyer" target="nms:recipient" type="link"/>

The reverse link (revlink) is generated (and can be viewed in the Preview) but not stored in the database as shown in the nms:recipient schema Preview:

<element label="order" name="order-buyer" revLink="buyer" target="neo:order" type="link" unbound="true">

      <join xpath-dst="@buyer-id" xpath-src="@id"/>

    </element>

To define a true M:M relationship you have to define a table to hold each relationship. This has been done with the xtk:rights schema that is used to configure the Operator rights on folders. Each entry in this table has a link to an Operator or Operator Group and a link to a Folder:

   <element desc="Right associated to folder" label="Folder" name="folder" revIntegrity="own"

             revLabel="Rights" revLink="rights" target="xtk:folder" type="link"/>

    <element label="Operators or groups" name="operator" revIntegrity="own" revLabel="Rights"

             revLink="rights" target="xtk:opsecurity, xtk:operator" type="link"/>

Hope this helps!

2 replies

ruby_comp
Level 2
June 20, 2014

1) M:M

2) Add a database index to the srcSchema

3) Impact would be improved speed

Linda_Stinson
Adobe Employee
Linda_StinsonAdobe EmployeeAuthorAccepted solution
Adobe Employee
June 27, 2014

Keeping in mind that every order has a single buyer, but every buyer (Recipient) can have multiple orders, you would define the link in the order schema.  Most relationships are 1:1 in one direction and 1:M in the reverse direction.  You define the link in the 1:1 "direction". This has been done with neo:order.

    <element label="buyer" name="buyer" target="nms:recipient" type="link"/>

The reverse link (revlink) is generated (and can be viewed in the Preview) but not stored in the database as shown in the nms:recipient schema Preview:

<element label="order" name="order-buyer" revLink="buyer" target="neo:order" type="link" unbound="true">

      <join xpath-dst="@buyer-id" xpath-src="@id"/>

    </element>

To define a true M:M relationship you have to define a table to hold each relationship. This has been done with the xtk:rights schema that is used to configure the Operator rights on folders. Each entry in this table has a link to an Operator or Operator Group and a link to a Folder:

   <element desc="Right associated to folder" label="Folder" name="folder" revIntegrity="own"

             revLabel="Rights" revLink="rights" target="xtk:folder" type="link"/>

    <element label="Operators or groups" name="operator" revIntegrity="own" revLabel="Rights"

             revLink="rights" target="xtk:opsecurity, xtk:operator" type="link"/>

Hope this helps!