Question about when a projection from a fiber product is open This is lemma 9.5.6 in Vakil's Foundations of Algebraic Geometry.
Let $X$ and $Y$ be schemes over a field $k$. Then, we want to prove that the projection $X \times_k Y \rightarrow Y$ is open.
First reduce to affine schemes, so we have $k$-algebras $A$ and $B$, and we need to prove that $B \rightarrow A \otimes_k B$ induces an open map $\operatorname{Spec} (A \otimes_k B) \rightarrow \operatorname{Spec} (B)$ is an open map.
Let $f =\sum_{i=1}^n a_i \otimes b_i \in A \otimes_k B$, and we want to prove that the image of $D(f)$ in $\operatorname{Spec}(B)$ is open. To do so, let $A'$ be the subring of $A$ generated by the $a_i$. Then, $A'$ is finitely generated over $k$. The ring homomorphism factors as $B \rightarrow A' \otimes_k B \rightarrow A \otimes_k B$.
This is the part where I don't understand. Vakil says we can now replace $A$ with $A'$. What is the relationship between the image of $D(f) \subseteq A \otimes_k B$ and $D(f) \subseteq A' \otimes_k B$?  $A' \rightarrow A$ is injective, and $B$ is flat as a $k$-module, but injective morphisms don't correspond to open maps between schemes.
 A: Reminder:  if we have a map of rings $\varphi:R\to S$, the corresponding map on spectra $\operatorname{Spec} S\to \operatorname{Spec} R$ is determined by sending the prime ideal $\mathfrak{p}\subset S$ to the prime ideal $\varphi^{-1}(\mathfrak{p})\subset R$.
Saying the ring homomorphism factors as $B\to A'\otimes_kB\to A\otimes_k B$ is the same as saying that the map on spectra factors as $\operatorname{Spec} A\otimes_k B\to \operatorname{Spec} A'\otimes_k B \to \operatorname{Spec} B$. So for each prime ideal $\mathfrak{p}\subset A\otimes_k B$ with preimage $\mathfrak{q}\subset B$, it's preimage $\mathfrak{p}'$ inside $A'\otimes_k B$ is a prime ideal which has preimage $\mathfrak{q}\subset B$ as well. This shows that the image of $D(f)\subset \operatorname{Spec} A\otimes_k B$ in $\operatorname{Spec} B$ is contained inside the image of $D(f) \subset \operatorname{Spec} A'\otimes_k B$ in $\operatorname{Spec} B$.
Now we want to show that the image of the 2nd $D(f)$ can't be any bigger. Pick a prime ideal $\mathfrak{q}\subset B$ in the image of the 2nd $D(f)$. This means that $(A'\otimes_k B)_f\otimes_B \kappa(\mathfrak{q})=(A'\otimes_k\kappa(\mathfrak{q}))_f$ is nonzero, so $A'\otimes_k\kappa(\mathfrak{q})$ is nonzero and the image of $f$ in it isn't nilpotent.  By injectivity of $A'\to A$, we get that $A'\otimes_k\kappa(\mathfrak{q})\to A\otimes_k\kappa(\mathfrak{q})$ is also injective, so $(A\otimes_k B)\otimes_B \kappa(\mathfrak{q})=A\otimes_k\kappa(\mathfrak{q})$ is also not the zero ring, nor is the image of $f$ in it nilpotent. So there is some point in $\operatorname{Spec} A\otimes_kB$ which maps to $\mathfrak{q}\in\operatorname{Spec} B$, and we're done. The images of $D(f)$ under the two maps are the same.
