logihooks

I have created a building object and in Building object i have created Flat object . I have assigned a building to "km". my question is how to write logichooks through after_relationship_add ,  all flats of building assigned to same name km?