Skip to content
Carlo Barazzetta edited this page Dec 4, 2018 · 5 revisions

Example - Class Definition with External Attributes

Here is a snippet from an example class definition with external attributes. The storage name for the class TTest is assumed to be Test:

  TTest2 = class(TInstantObject)
  {IOMETADATA stored;
    TestPart: Part(TTest) external;
    TestParts: Parts(TTest) external 'Test2_TestParts';
    TestRef: Reference(TTest);
    TestRefs: References(TTest) external 'Test2_TestRefs'; }

The TestPart attribute is an external part attribute, which results in a mapping very similar to TestRef. Instead of having a blob field called TestPart, the Test2 table has two reference fields, TestPartId and TestPartClass, and the referenced TTest object's attributes are stored as a record in the Test table .

The TestParts external attribute results in the creation of a linking table named Test2_TestParts which has relationships with both Test2 andTest: Test2 --1:N--> Test2_TestParts --1:1--> Test. The Test2_TestParts linking table has fields to hold information about both the relationships and the sequence of elements in the TestPart sattribute.

The mapping of the TestRefs attribute is very similar to that for the TestParts attribute. The only difference is that the TestParts attribute's Test table records are deleted when the related Test2 table record is deleted. This cascade delete process, of course, does not happen with the TestRefs attribute's Test table records.

Clone this wiki locally