Skip to main content
Solved

PXProjection with LEFT JOIN and Optional Child Records - How to Define Keys?

  • July 24, 2026
  • 3 replies
  • 25 views

Forum|alt.badge.img+2

Hi everyone,

I'm working on a PXProjection that joins a parent table with a child table using a LEFT JOIN.

The relationship is one-to-many:

  • One parent record can have multiple child records.
  • Some parent records may have no child records at all.

The projection itself works as expected, but I'm unsure how the DAC keys should be defined.

The child table has a key field that is part of the projection's key. When there is no matching child record because of the LEFT JOIN, that key is NULL. However, a key field in a DAC cannot be null 

What is the recommended approach for defining keys in this type of projection?

  • Should only the parent table's key fields be marked with IsKey = true?
  • Is there a best practice for projections that include optional child records?
  • How do you handle one-to-many relationships where the child record may not exist?

I'd appreciate any guidance or examples. Thanks!

Best answer by darylbowman

What is the motivation for the PXProjection? Could you join the child records in a view instead?

I need view with data from header and from detail Lines. 

I think you should be able to achieve this without a projection though.

 

...but I'm unsure how the DAC keys should be defined.

Obviously, the resulting pseudo-record needs to differentiate itself from the other resulting records. If you were grouping by the parent record, resulting in only one parent, the parent keys would be sufficient. If the results could have matching parent records, I’m not sure a PXProjection is designed for that scenario.

3 replies

darylbowman
Captain II
Forum|alt.badge.img+17

What is the motivation for the PXProjection? Could you join the child records in a view instead?


Forum|alt.badge.img+2
  • Author
  • Captain I
  • July 24, 2026

What is the motivation for the PXProjection? Could you join the child records in a view instead?

I need 2 field from header and 2 from detail Lines. Group him by 4 field and sum Amount and Qty. In result I need view with data from header and from detail Lines. 


darylbowman
Captain II
Forum|alt.badge.img+17

What is the motivation for the PXProjection? Could you join the child records in a view instead?

I need view with data from header and from detail Lines. 

I think you should be able to achieve this without a projection though.

 

...but I'm unsure how the DAC keys should be defined.

Obviously, the resulting pseudo-record needs to differentiate itself from the other resulting records. If you were grouping by the parent record, resulting in only one parent, the parent keys would be sufficient. If the results could have matching parent records, I’m not sure a PXProjection is designed for that scenario.