Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Using Relationships

Question
John Bland · Jul 24, 2019

Using Relationships

In Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2018.1.2 (Build 309U) Mon Mar 4 2019 15:07:46 EST

I have a master record that has a relationship to a table with multiple transactions, and the transaction table has a relationship to another transaction table with multiple other transactions.

IE Item to Physcal to Physical Report

Item Master:

Relationship PhysicalRecord As User.pytrn [ Cardinality = many, Inverse = ItemRecord ];

First transaction table

Relationship ReportRecords As User.pyrpt [ Cardinality = many, Inverse = PhysicalRecord ];

Relationship ItemRecord As User.immst [ Cardinality = one, Inverse = PhysicalRecord ];

Second Transaction table

Relationship PhysicalRecord As User.pytrn [ Cardinality = one, Inverse = ReportRecords ];

Everything compiles with no issues and all records have the appropriate data (IDs).

    In SQL why does

select pyrpt.pypqty,PhysicalRecord->pypqty as pypqty1, PhysicalRecord->ItemRecord->imdesc from SQLUser.pyrpt

return the imdesc field from the master table, but

select pyrpt.pypqty, PhysicalRecord->ItemRecord->imdesc from SQLUser.pyrpt

 does not?  Why do I have to force swizzling to occur for the two layer access to operate.

    John P. Bland

#Caché

Source URL:https://community.intersystems.com/post/using-relationships