Post regarding Hartshorne II Ex. 3.1. 3.1. Show that a morphism $f : X \to Y$ is locally of finite type if and only if for every open affine subset $V = \textrm{Spec} \, B$ of $Y$, $f^{-1}(V)$ can be covered by open affine subsets $U_j = \textrm{Spec} \, A_j$ is a finitely generated $B$-algebra.
There is a post with a proof of the forward direction, if $f$ is locally of finite type then the latter property holds, here:
Question on morphism locally of finite type
I have some questions about this proof.

*

*So $V'$ is an open subset in the covering of $V \cap V_i$ and we need it to be a distinguished, open, affine subset for the open subschemes $V$ and $V_i$ of $Y$. Then we have the isomorphisms
\begin{align*}
V' &\cong (D(g), \mathscr{O}_Y|_{D(g)}) \cong (\textrm{Spec} \, B_g, \mathscr{O}_{\textrm{Spec} \, B_g}) \\
&\cong (D(g_i), \mathscr{O}_Y|_{D(g_i)}) \cong (\textrm{Spec} \, B_{g_i}, \mathscr{O}_{\textrm{Spec} \, B_{g_i}})
\end{align*}
as locally ringed spaces. Is this all correct?


*We need to further cover the preimage $f^{-1}(V)$ by affine, open subsets. Out of interest, can it happen that $f^{-1}(V)$ is already affine? Is there a name for morphisms with $f^{-1}(V)$ open affine whenever $V$ is?


*I do not understand the purpose of $U_{i, j}$ and $U'$. Are we saying that $U'$ is $U_{i, j}$ for some $i, j$?


*Where does the ring $A_{i, j}$ come from? It is said that $\textrm{Spec} \, f$ is $\varphi_{i, j} : B_i \to A_{i, j}$ and so it would appear that $A_{i, j}$ is the ring of global sections for $U_{i, j}$. In other words, $U_{i, j}$ is affine and $(U_{i, j}, \mathscr{O}_X|_{U_{i, j}}) \cong (\textrm{Spec} \, A_{i, j}, \mathscr{O}_X|_{\textrm{Spec} \, A_{i, j}})$ as locally ringed spaces.  Is this correct?


*I do not see why the existence of $\varphi_{i, j}$ makes $A_{i, j}$ a finitely generated $B_i$-algebra. I can see that $\varphi_{i, j}$ gives $A_{i, j}$ the structure of a $B_i$-algebra, but why is it finitely generated?


*Presumably, the localisation of $\varphi_{i, j}$ refers to the map $B_i \to (A_{i, j})_{f_{i, j}} = \mathscr{O}_X(U')$ that is given to us by the universal property for localisation. I do not understand the part about the map $\varphi : B \to (A_{i, j})_{f_{i, j}}$.
There is more to the proof, but I would like to understand this to begin with. Thank you for your time and I apologise because I have asked rather a lot of questions.
 A: Well, regarding your first point, you know that $V'$ is simultaneously a distinguished open subscheme of $V$ and $V_i$; this means that $(V', \mathcal{O}|_{V'})$ is isomorphic to both $(D(g),\mathcal{O}_V|_{D(g)})$ and $(D(g_i),\mathcal{O}_{V_i}|_{D(g_i)})$, so in particular the two latter schemes are also isomorphic (note the change in notation: you wrote $\mathcal{O}_Y|_{D(g)}$. Strictly speaking, $g$ is a regular function on $V$, not on $Y$, but this is only a matter of notation, so don't worry much about this).
For your second question, those morphisms such that $f^{-1}(V)$ is affine for $V$ affine are called, surprisingly, affine morphisms. Closed immersions are examples of affine morphisms.
Your third, fourth and fifth questions are all answered at the statement of the question you linked; all the open sets, rings and morphisms involved come from the very definition of locally of finite type morphism.
Finally, you're right that by localisation of $\varphi_{ij}$ he refers to the map $B_i\rightarrow (A_{i,j})_{f_{ij}}$. Now, by construction , the open set $U'$ is contained in $f^{-1}(V\cap V_i)$, so the restriction of $f$ to this open $U'$ can be regarded as a morphism $U'\rightarrow V_i$ (from where you get the map of rings $\varphi_{ij}$) and as a morphism $U'\rightarrow V$, which is given by a map of rings $\varphi:B\cong \mathcal{O}_Y(V)\rightarrow (A_{i,j})_{f_{ij}}$. This is where $\varphi$ comes from. Once he proves that this $\varphi$ makes $(A_{i,j})_{f_{ij}}$ into a finitely generated $B$-algebra, he is done with the  proof: he has found an open affine covering of $f^{-1}(V)$, made of the open sets $U'$, such that the restriction of $f$ to each of these $U'$ makes $\mathcal{O}_Y(V)$ into a finitely generated $\mathcal{O}_X(U')$-algebra, which is the very thing you want to prove.
