Take a look at the Checkbox set selector. It does a lot with references, I'm sure that should give you the insight you need.
Either way, you can use obj.addReference(refname, guid) on the owner obj of the relation.
Remember that all entities/associations/microflows start with their Module_Name as in MyFirstModule/MyMicroflow or MyFirstModule/Object_OtherObject. You should keep hardcoded strings out of your code and set these as parameters in your XML.