Questions on Gluing Schemes I am trying to do an exercise in a book and here is the question. I have attempted it but I am not sure if my answer is correct. I would appreciate if someone corrects my attempt. Note here that the question has 3 parts...
Question: Let $Y$ be an integral scheme (a scheme that is reduced and irreducible), and $U$ be a non-empty open subscheme. Let $I$ be a non-empty index and for all $i\in I$, we let $U_{i}:=U_{ii}=Y$ and $U_{ij}=U$ if $i\neq j$. Let $\phi_{ji}:U_{ij}\rightarrow U_{ji}$ be the identity map and $X$ be a scheme glued along $\phi_{ij}$.
1) We need to show that for all $V$ open subset of $X$, and for all $i\in I$, we have an isomorphism $\Gamma(V,\mathcal{O}_{X})\rightarrow \Gamma(V\cap U_{i},\mathcal{O}_{X})$.
Attempt
Since $Y$ is irreducible and closed, so it has a generic point $\eta$ which lies in every open set, and therefore it lies in $U$. Then $X$ has a generic point which is $\eta$ as well. I consider the inclusion of schemes $i:U_{i}\rightarrow X$. Therefore, this induces the morphism of function fields:
$\displaystyle i^{\#}_{\eta}:\mathcal{O}_{X,\eta}\rightarrow \mathcal{O}_{U_{i},\eta},$
which is an isomorphism (I think? because $U_{i}\subseteq X$). Therefore, for each $x\in X$, we have an isomorphism $\mbox{Frac}(\mathcal{O}_{X,x})\rightarrow \mbox{Frac}((i_{*}\mathcal{O}_{U_{i}})_{x})$, and hence (I believe this to be true) an isomorphism of stalks $i^{\#}_{x}: \mathcal{O}_{X,x}\rightarrow (i_{*}\mathcal{O}_{U_{i}})_{x}$. This means that $i^{\#}:\mathcal{O}_{X}\rightarrow i_{*}\mathcal{O}_{U_{i}}$ is an isomorphism (at this stage I only know that this is a bijection, so I am taking a leap of faith here and conclude that it is an isomorphism), which is exactly what we want (I hope).
2) Assume that $U\neq Y$, conclude from (1) that $X$ is not an affine scheme.
Attempt
I am stuck on this one for a long time, and this is the best I can come up with. If $X=(\mbox{Spec}A,\mathcal{O}_{\mbox{Spec}A})$, using the previous result, we have an isomorphism $A\rightarrow \Gamma(X\cap U_{i},\mathcal{O}_{X})=\Gamma(U_{i},\mathcal{O}_{U_{i}})=\Gamma(Y,\mathcal{O}_{Y})$. Now, we set $V=U_{j}$ where $j\neq i$. Then again we have an isomorphism
$\Gamma(Y,\mathcal{O}_{Y})=\Gamma(U_{j},\mathcal{O}_{X})\rightarrow\Gamma(U_{i}\cap U_{j},\mathcal{O}_{X})=\Gamma(U,\mathcal{O}_{X})$
(I think this isomorphism is fishy but I will take it with faith). Now my hope is that since $U$ is a proper open subset of $X$, and $X$ is an affine scheme, the restriction to proper open subset of $\mbox{Spec}A$ will never induce an isomorphism of sections. But this is what we see since $\Gamma(X,\mathcal{O}_{X})\cong \Gamma(U,\mathcal{O}_{X})$.
3) Now assume $Y$ is a noetherian scheme and $U\neq Y$. Prove that $X$ is integral and locally Noetherian. Furthermore, show that $X$ is quasi-compact if and only if the indexing set $I$ is finite.
To show that $X$ is quasi-compact if the indexing set is finite, this comes from the fact that $Y$ is quasi-compact. To show that $X$ is locally noetherian, since $Y$ admits an open affine covering $V_{i}$ such that $\Gamma(V_{i},\mathcal{O}_{Y})$ is noetherian, so $X$ admits an open affine covering, where the section of each of the covering open affine subset is noetherian. I can't answer why $X$ should be an integral scheme.
Remark: I know this is a bit long, but I really appreciate if someone helps me to proof-read my proofs.
Thanks! 
 A: Your solution to (1) is not quite correct. The right way to do this is to go back to the construction of the glueing procedure, and think about what it does to the sheaves. To give a section $f$ of $\mathcal O_X$ over $V$ is essentially the same as to give a compatible collection $f_i$ of sections of $\mathcal O_{U_i}$ over  $U_i \cap V$. "Compatible" here means the only possible thing using the transition maps $\phi_{ij}$. In the case that you have, the transition maps are equalities, so the condition is that the sections $f_i$ and $f_j$ should become equal in $\Gamma(X, U)$. But the restriction maps of the structure sheaf of an integral scheme are injective, so the data of the collection $\{f_i\}$ is really equivalent to the data of any one of them. I'll let you formalize this a bit.
For (2), you have the right idea, but it's perhaps best stated this way: the open immersion $U_i \hookrightarrow X$ induces an isomorphism on global sections by (1), so if $X$ were affine, it would be an isomorphism (recall that the category of affine schemes is anti-equivalent to the category of rings). But on points, it is not surjective (recall how the underlying topological spaces were glued).
(3) Looks good. To show $X$ is integral, you should refer back to (1), and use the assumption that $U_i$ is integral. 
