Definition: A morphism $f:X\to Y$ of schemes is locally of finite type if there exists a covering of $Y$ by open affine subsets $V_i=\mathrm{Spec}(B_i)$, such that for each $i$, $f^{-1}(V_i)$ can be covered by open affine subsets $V_i=\mathrm{Spec}(A_{ij})$, where each $A_{ij}$ is a finitely generated $B_i$-algebra.
Exercise 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=\mathrm{Spec}(B)$ of $Y$, $f^{-1}(V)$ can be covered by open affine subsets $U_j=\mathrm{Spec}(A_j)$, where each $A_j$ is a finitely generated $B$-algebra.
The 'if' direction is trivial, so I'm asking about the 'only if' direction.
Assume that $f:X\to Y$ is locally of finite type and let $V=\mathrm{Spec}(B)$ an open affine subset of $Y$. I can use the covering of $Y$ given by the hypothesis to obtain a covering of $V\subseteq\bigcup_i V_i=\bigcup_i \mathrm{Spec}(B_i)$, so $f^{-1}(V)\subseteq \bigcup_i f^{-1}(V_i)\subseteq\bigcup_{i,j}\mathrm{Spec}(A_{ij})$. Since $A_{ij}$ is a finitely generated $B_i$-algebra, it would suffice to show that $B_i$ is a finitely generated $B$-algebra.
Using this question I can find $\mathrm{Spec(R)}\subseteq \mathrm{Spec}(B)\cap \mathrm{Spec}(B_i)$, so inclusions of topological spaces give rise to ring homomorphism $\varphi:B\to R$ and $\psi:B_i\to R$. What I need to show then is that $R$ is a finitely generated $B_i$-algebra and that there exists a ring homomorphism $\theta: B\to B_i$ such that $\psi\circ\theta=\varphi$.
Is my idea right? If so, how can I complete it? Is there any better way to solve this exercise? Thank you.