Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Scenario 5: Modelling the Buyer to Sales transaction relationship

Linda_Stinson
Employee
Employee

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?

1 Accepted Solution
Linda_Stinson
Correct answer by
Employee
Employee

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!

View solution in original post

2 Replies
ruby_comp
Level 2
Level 2

1) M:M

2) Add a database index to the srcSchema

3) Impact would be improved speed

Linda_Stinson
Correct answer by
Employee
Employee

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!

View solution in original post