2

One to One Relationships

There was a question yesterday about creating a one to one relationship.

It got me thinking about this. I think there are situations when having a one to one relationship is the correct solution, such as here where  is looking to link a bank import to account transactions.

I put together a solution for this using two relationships pointing in opposite directions, with the one side showing and the many side hidden.

 On the Trigger on update of the one side I use this script

let a := this;
if Bank = null then
    first('Bank Many').(Accounts := 0)
else
    Bank.(Accounts := a)
end

with a constraint of

b.Accounts = null

with similar versions for the other table. These keep both relationships in sync.

Regards John

Reply

null