Relationship 3 tables

Hi,
?
I have 3 tables, Detail, Header and Accounts.

Detail (id, header_id, xxx) (n, 1)
Header (id, name, xxx) (1, n)
Accounts (id, header_id, xxx) (n, 1)

When I give a PUT (Detail) through the relationship it writes Detail and Header correctly. But I need to give a PUT (Accounts) and it is duplicating the Header, because already recorded one when I passed the Detail.

I do not know how I could make this right relationship to record all three at once. Or you would have to retrieve the Header ID(Last insert) to pass when you are writing Accounts ( Put(Accounts) ).

Could anyone help me with this question?

I did not realize that with the lazy it creates a LIST field that references the child tables, solved here.