Relationship resets itself after setting new value

Hi, I am working with a 1:N relationship which I would like to update and I am experiencing an odd problem that the relationship seems to reset itself.
I check the database and I see two records that seemed to have been written in the exact same second. One is the updated version I was trying to write but this is set to deleted and there is an additional record that restored the old relationship (with a new record, the original record still exist - set to deleted) .
The time stamp provides no hints which was first but I assume my update is somehow overwritten right away with the prior state of the relationship, which I don’t understand.

My code looks like this:
My 1:N (newLinkBean : relationshipHoldingBean) relationship looks like this

if ($relationshipHoldingBean){
            } else {
                //error out
// Set more field values

I get no erros but I am wondering if I this is correct? There might be already a relationship and I am trying to override it / update it. If the relationship is not set yet adding it works as expected but I assume I am missing something here for the case that there is already a record in this 1:N relationship ?
I tried the same also via SQL directly but it lead to the same result. Is there a trick how to update 1:N relationships?

You wrote: " There might be already a relationship and I am trying to override it / update it" It’s correct. You check relationship and if it is exist you add it the second time.
Why are you writing this code? What is you target?