12.07.2015 Views

Using Caché Globals - InterSystems Documentation

Using Caché Globals - InterSystems Documentation

Using Caché Globals - 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.

SQL and Object Use of Multidimensional Storage^MyApp.PersonD = 2 // counter node^MyApp.PersonD(1) = $LB("Student",19,"Jack")^MyApp.PersonD(1,"Student") = $LB(3.2,"Physics")^MyApp.PersonD(2) = $LB("Student",20,"Jill")^MyApp.PersonD(1,"Student") = $LB(3.8,"Chemistry")The properties inherited from the Person class are stored in the main node, and those introduced bythe Student class are stored in an additional subnode. This structure ensures that the Student data canbe used interchangeably as Person data. For example, an SQL query listing names of all Person objectscorrectly picks up both Person and Student data. This structure also makes it easier for the ClassCompiler to maintain data compatibility as properties are added to either the super- or subclasses.Note that the first piece of the main node contains the string “Student” — this identifies nodes containingStudent data.4.1.4 Parent-Child RelationshipsWithin parent-child relationships, instances of child objects are stored as subnodes of the parent objectto which they belong. This structure ensures that child instance data is physically clustered along withparent data.For example, here is the definition for two related classes, Invoice:/// An Invoice classClass MyApp.Invoice Extends %Persistent [ClassType = persistent]{Property CustomerName As %String;/// an Invoice has CHILDREN that are LineItemsRelationship Items As LineItem [inverse = TheInvoice, cardinality = CHILDREN];}and LineItem:/// A LineItem classClass MyApp.LineItem Extends %Persistent [ClassType = persistent]{Property Product As %String;Property Quantity As %Integer;/// a LineItem has a PARENT that is an InvoiceRelationship TheInvoice As Invoice [inverse = Items, cardinality = PARENT];}If we store several instances of Invoice object, each with associated LineItem objects, the resultingglobal will be similar to:38 <strong>Using</strong> <strong>Caché</strong> <strong>Globals</strong>

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

Saved successfully!

Ooh no, something went wrong!