Exact sequence induced by decomposition of a variety Let $X=Y_1\cup Y_2$.
Denote $I:=\mathcal{I}(X)$, $I_1:=\mathcal{I}(Y_1)$, $I_2:=\mathcal{I}(Y_2)$. Then we have $I=I_1\cap I_2$.

In this question, the answer suggests that there is an exact sequence
  $$
0\rightarrow R/I\rightarrow R/I_1\oplus R/I_2\rightarrow R/(I_1+I_2)\rightarrow 0
$$
  Could anyone explain to me how to construct such sequence?

I can figure it out in the special case where $Y_1\cap Y_2=\varnothing$. Because if so we have $I_1+I_2=R$, and in the polynomial ring which is Dedekind, we have
$$
(I_1+I_2)(I_1\cap I_2)=I_1I_2
$$
which implies $I_1I_2=I_1\cap I_2$. Now the above exact sequence degenerate into an isomorphism
$$
R/(I_1I_2)\rightarrow R/I_1\oplus R/I_2
$$
which can be constructed easily by using Chinese Reminder Theorem.
However, I fail to see the sequence in general case. Please help.
 A: First, recall that for $I \subseteq J$ an inclusion of ideals, there is a natural surjection $R/I \twoheadrightarrow R/J$ (which should be viewed as part of the short exact sequence $0 \to J/I \to R/I \to R/J \to 0$ coming from the Third Isomorphism Theorem $(R/I)/(J/I) \cong R/J$). Thus, if $I_1, I_2$ are any ideals, we have
i) Two maps $R/(I_1 \cap I_2) \to R/I_1$ and $R/(I_1 \cap I_2) \to R/I_2$, which together induce a map $\varphi : R/(I_1 \cap I_2) \to R/I_1 \times R/I_2$. Explicitly, $\varphi(x + (I_1 \cap I_2)) = (x + I_1, x + I_2)$ is a "diagonal" map.
ii) Two maps $R/I_1 \to R/(I_1 + I_2)$ and $R/I_2 \to R/(I_1 + I_2)$, which give a "difference" map $\phi : R/I_1 \oplus R/I_2 \to R/(I_1 + I_2)$, sending $\phi(x + I_1, y + I_2) := x - y + (I_1 + I_2)$. Thus, we get a sequence
$$0 \to R/(I_1 \cap I_2) \xrightarrow{\varphi} R/I_1 \times R/I_2 \xrightarrow{\phi} R/(I_1 + I_2) \to 0$$
which can be checked to be exact (the only difficult step is showing $\ker \phi \subseteq \operatorname{im} \varphi$, see e.g. here). This in fact proves the Chinese Remainder Theorem, which is the special case when the last term is $0$, i.e. $I_1 + I_2 = R$.
