Extension and contraction of ideals