If Spec A is over Spec R, then why A is an R-algebra? 
If $\operatorname{Spec}A$ is over $\operatorname{Spec}R$, then why $A$ is an $R$-algebra?

I just don't see why, can somebody explain? Thank you!
 A: Saying "$\operatorname{Spec} A$ is over $\operatorname{Spec} R$" means there's a morphism $\operatorname{Spec} A\to \operatorname{Spec} R$. Using the fact that $\operatorname{Spec}$ is a contravariant equivalence of categories between affine schemes and algebras, we see that there is a natural map $R\to A$ here corresponding to the morphism $\operatorname{Spec} A\to \operatorname{Spec} R$. This map gives $A$ a natural structure of an $R$-algebra.
A: To the datum of a scheme morphism $f\colon \mathrm{Spec}(A)\to  \mathrm{Spec}(R)$ there belongs a morphism of sheaves of rings $\mathcal{O}_{ \mathrm{Spec}(R)}\to f_*\mathcal{O}_{ \mathrm{Spec}(A)}$ (with some local property irrelevant to the question). Looking at the map on global sections gives the desired ring homomorphism
$$R=\mathcal{O}_{ \mathrm{Spec}(R)}(\mathrm{Spec}(R))\to f_*\mathcal{O}_{\mathrm{Spec}(A)}(\mathrm{Spec}(R))=\mathcal{O}_{\mathrm{Spec}(A)}(\mathrm{Spec}(A))=A.$$ This map provides $A$ with the structure of an $R$-algebra.
