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?
Solved! Go to Solution.
Views
Replies
Total Likes
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!
Views
Replies
Total Likes
1) M:M
2) Add a database index to the srcSchema
3) Impact would be improved speed
Views
Replies
Total Likes
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!
Views
Replies
Total Likes
Views
Likes
Replies