Vanishing ideal of the fiber product of two affine sets Let $\Bbbk$ be an algebraically closed field of characteristic $0$ (just to keep it simple). Assume we are given three affine sets $X\subseteq\mathbb{A}_{\Bbbk}^n,Y\subseteq\mathbb{A}_{\Bbbk}^m$ and $Z\subseteq\mathbb{A}_{\Bbbk}^l$ and two polynomial maps $f:X\to Z$ and $g:Y\to Z$. I would like to show that
$$X\times_Z Y:=\left\{(a,b)\in X\times Y\mid f(a)=g(b)\right\}$$
is an affine set by providing explicitly its vanishing ideal.
Assume that $\Bbbk[X]=\Bbbk[X_1,\ldots,X_n]/\langle p_1,\ldots,p_r\rangle, \Bbbk[Y]=\Bbbk[Y_1,\ldots,Y_m]/\langle q_1,\ldots,q_s\rangle$ and that $\Bbbk[Z]=\Bbbk[Z_1,\ldots,Z_l]/\langle o_1,\ldots,o_t\rangle$. My guess is that
$$\mathcal{J}(X\times_Z Y)=\langle P_1,\ldots,P_n,Q_1,\ldots,Q_m,Z_1( F-G),\ldots,Z_l(F-G)\rangle\subseteq \Bbbk[X_1\ldots,X_n,Y_1\ldots,Y_m],$$
where
$$
P_i(X_1,\ldots,X_n,Y_1,\ldots,Y_m)=p_i(X_1,\ldots,X_n), \\ Q_j(X_1,\ldots,X_n,Y_1,\ldots,Y_m)=q_j(Y_1,\ldots,Y_m), \\
\big(Z_k(F-G)\big)(X_1,\ldots,X_n,Y_1,\ldots,Y_m) = f_k(X_1,\ldots,X_n)-g_k(Y_1,\ldots,Y_m)
$$
(the $k$-th component of the polynomial functions). It's not difficult to show that
$$
\mathcal{J}(X\times_Z Y)\supseteq\langle P_1,\ldots,P_n,Q_1,\ldots,Q_m,Z_1( F-G),\ldots,Z_l(F-G)\rangle
$$
but I am having some troubles in showing the converse.
Does anybody have an idea?
 A: Thinking of $X\times_Z Y$  embedded in $\mathbb{A}^{n}\times \mathbb{A}^m$ you can write down the fiber product as an intersection
$$
\mathbb{A}^n \times Y \cap X\times \mathbb{A}^m \cap \{(a,b)\mid f(a)=g(b) \}
$$
and use the Nullstellensatz. You'll get the radical of  the ideal you wrote. 
However, for this ideal to be radical or not depends on $f$ and $g$ (assuming $X$ and $Y$ reduced).
Example: Consider $X = \mathcal{V}(y-x^2)\subset \mathbb{A}^2$, $Y = \mathcal{V}(z) \subset \mathbb{A}^1$, $Z = \mathbb{A}^1$, $f(x,y)=y$ and $g(z)=z$. Then in $k[x,y,z]$ we have
$$
\left< y-x^2, z, y-z \right> = \left< x^2, z, y \right> 
$$
which is not radical. Geometrically we are restricting the projection $f$ to the parabola $X$ and $X\times_Z Y$ is the fiber over the point $\mathcal{V}(z) \in \mathbb{A}^1$ that is a double point. Note that in this case $\mathcal{J}(X\times_Z Y) = \left< x, z, y \right> $.
If we choose $g(z)=z+1$, then 
$$
\left< y-x^2, z, y-z-1 \right> = \left< 1-x^2, z, y-1 \right> 
$$
which give you two distinct points and the ideal is radical.
