25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14.4 Persistent Behavior of Relationships<br />

Though there are two sides to every relationship, only one side actually has its relationshiprelated<br />

information stored to disk. This is the single-valued side, the PARENT or ONE of<br />

the relationship.<br />

When you open an instance of the multi-valued side of a relationship, <strong>Caché</strong> treats its relationship<br />

property as a standard object reference; it opens and swizzles into memory the<br />

PARENT or ONE object. When you open an instance of the single-valued side of a relationship,<br />

<strong>Caché</strong> uses a query to locate and create a list of all the relevant CHILDREN or MANY<br />

instances; to improve performance of this operation, on the multi-valued side, create an index<br />

on the relationship property. This also improves performance of the Execute, Fetch, and<br />

Close methods. When defining a relationship property, Studio asks if you want such an index.<br />

14.4.1 Referential Integrity<br />

Relationships maintain referential integrity by enforcing constraints and invoking referential<br />

actions. When a relationship is saved, <strong>Caché</strong> checks for the existence of the target of its reference.<br />

If the target does not exist, then <strong>Caché</strong> returns an error and the save operation fails.<br />

When an object is deleted and there are objects related to it, the related objects are deleted<br />

(parent/child cardinality) or the delete operation fails (one/many cardinality).<br />

14.4.2 Persistent Behavior of Dependent Relationships<br />

With parent/child relationships, deleting the parent kills the children. Further, the storage of<br />

children is subordinate to that of the parent, in a structure similar to the following:<br />

^Inv(1)<br />

^Inv(1, "invoice", 1)<br />

^Inv(1, "invoice", 2)<br />

^Inv(1, "invoice", 3)<br />

...<br />

Persistent Behavior of Relationships<br />

Again, by associating the storage nodes of the CHILDREN with that of their PARENT, as<br />

is depicted above, <strong>Caché</strong> can read and write more quickly.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 131

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!