build relations based on field names