Hi Rommel,
Yes, this is possible with qRules. I have attached a form for your reference. Please check the rules on field1 under the group2 repeating group.
For inserting a row, I used the condition:
All occurances of field4 != field1
And for updating a row, I used the condtiion:
Any occurence of field4 = field1
where field4 and field1 are the IDs field for the both tables respectively.
For inserting rows with data, you will need to use the commands Insert and SetValue, and for updating rows you will need to identify with row by specifying the ID of the row and use the SetValue command to update the row.
I hope this makes sense. Please test this logic on your form and let us know how it goes.
Regards,