To associate and dissasocite N to N relationships I found this very usefull libraries thanks to Dave Berry.
To use it we simply have to call:
//AssociateEntities(relationshipSchemaName, entity1SchemaName, entity1KeyValue, entity2SchemaName, entity2KeyValue, skipCheck) AssociateEntities("lema_lema_sitevisit_epa_noncompliance", "epa_noncompliance", CIID, "lema_sitevisit", createResponse, true);
Find here the Associate Library. As usual I upload it as a .doc file. Rename it to .js to view it.