Why is the structure sheaf (sheaf of rings) $\mathcal{O}$ on $\mathrm{Spec}\ A$ a sheaf? Let $X = \mathrm{Spec}\ A$, and for each prime ideal $\mathfrak{p} \subseteq A$, let $A_{\mathfrak{p}}$ be the localization of $A$ at $\mathfrak{p}$. Now, for  each open set $U \subseteq X$, define $\mathcal{O}(U)$ to be the set of functions
$$s: U \rightarrow \coprod_{\mathfrak{p} \in U} A_{\mathfrak{p}}$$
such that $s(\mathfrak{p}) \in A_{\mathfrak{p}}$ for each $\mathfrak{p}$, and such that $s$ is locally a quotient of elements of $A$, that is, for each $\mathfrak{p} \in U$, there is some neighborhood $V_{\mathfrak{p}}$ of $\mathfrak{p}$ with $V_{\mathfrak{p}} \subseteq U$ and elements $a,f \in A$ such that for each $\mathfrak{q} \in V$ and $f \notin \mathfrak{q}$, $s(\mathfrak{q} )= a/f$ in $A_{\mathfrak{q}}$. My question is 

Why is the sheaf of rings $\mathcal{O}$ defined above a sheaf of rings?

While it seems clear that $\mathcal{O}$ is a presheaf, I fail to see why it satisfies the extra axioms that make it a sheaf. Hartshorne says "it is clear from the local nature of the definition that $\mathcal{O}$ is a sheaf", but while trying to prove it formally, I couldn't show that it is actually a sheaf. 
Also, I've just been fiddling around with the definitions for the moment trying to gain some insight about why this "provides a systematic way of keeping track of local algebraic data on $\mathrm{Spec}\ A$", but for now, it's just as mysterious as it was at the beginning. So if anyone could provide me some insight about why this is what we want to be our definition of structure sheaf, I'd be very grateful for that. Thank you in advance! 
 A: As someone who has experienced nearly constant frustration in verifying "obvious" claims in algebraic geometry textbooks, I didn't find this one to be too bad.
Let $U_i$ be an open cover of $U$, let $s \in \mathcal O_X(U)$, and suppose $s|U_i = 0$ for all $i$.  Now $s$ is a function from $U$ into the disjoint union of the rings $A_{\mathfrak p} : \mathfrak p \in U$.  To say that $s$ is the zero element is to say that $s(\mathfrak p)$ is zero in $A_{\mathfrak p}$ for all $\mathfrak p$.  So it is clear that $s = 0$.
Now suppose $s_i \in \mathcal O_X(U_i)$, and $s_i$ and $s_j$ agree on $U_i \cap U_j$ for all $i, j$.  Then it is clear that there is a unique function $s: U \rightarrow \coprod\limits_{\mathfrak p \in U} A_{\mathfrak p}$ whose restriction to $U_i$ is $s_i$ for all $i$.  Obviously, $s(\mathfrak p) \in A_{\mathfrak p}$ for all $\mathfrak p$, and the question now is whether $s$ is locally a quotient of elements from $A$.  
Let $\mathfrak q \in U$.  Then $\mathfrak q $ lies in some $U_i$, and since $s_i = s|U_i$ is in $\mathcal O_X(U_i)$, there exists an open neighborhood $V$ of $\mathfrak q$ and elements $a, f \in A$, with $f \not\in \mathfrak p$ for any $\mathfrak p \in V$, such that $s_i(\mathfrak p) = \frac{a}{f} \in A_{\mathfrak p}$ for all $\mathfrak p  \in V$.  But $s_i(\mathfrak p ) = s(\mathfrak p)$, done.
A: This is really a case when you are thinking about a sheaf as an espace etale rather than as a presheaf satisfying glueing axioms. The espace etale view of a sheaf over $X$ is that it's a continuous map $Y\to X$
which is locally a homeomorphism. So here $X$ is the space Spec$\,A$
and the espace etale starts off as this disjoint union of localisations $A_\frak p$. We need to give $\coprod A_\frak p$ a topology in order
for the projection map to be a local homeomorphism. Hartshorne is arguing in effect that a basis for a suitable topology consists of the $a/f$
in the $A_\frak p$ for $\frak p$ in some $V$ where $f\notin \frak p$
for all ${\frak p}\in V$.
Of course the burden now is to prove that this is a basis for a topology,
and
with that topology the projection $\coprod A_{\frak p}\to\text{Spec}\,A$
is locally homeomorphic. In addition one must show the ring operations
are continuous in a suitable sense. This is the sort of thing that
writers leave "as an exercise for the reader" since it's more complicated to write up than they'd like.
A: Hartshorne p. 70 line 6 before the end says that this is clear from the local nature of the definition.
Suppose that $U$ is an open subset of $Spec(A), U=\bigcup U_i$, $s_i\in O(U_i)$ such that the restriction of $s_i$ and $s_j$ on $U_i\cap U_j$ coincide. The local nature says that  the definition of a section depends only of a neighborhood of a point $p\in U_i\subset U$, that is if the restriction of section $s:U\rightarrow \Pi_{p\in U}A_p$ to $U_i$ is an element of $O(U_i)$ for every $i$, then it is an element of $O(U)$ (this fact follows from the definition; the neigbhorhood $V_p$ and the elements $a,f$ that you use for $U_i$ can also be used for $U$), so the  map defined by $s_{\mid U_i}=s_i$ is an element of $O(U)$.
