fixed foreign key deletion for mixed associations

fix for #953. we are now checking if we still need the foreign key for other associations