The field of quotients of the ring of germs of functions. Let $Y\subseteq \mathbb{A}^n$ be an affine variety with affine co-ordinate ring $A(Y)=k[x_1\dots, x_n]/I(Y)$, where $k$ is an algebraically closed field.
Denote with $\mathcal{O}(Y)$ the ring of all regular functions $f\colon Y\to k$.
Fix an affine variety $Y$ and a point $P\in Y$. Let $U,V\subseteq Y$ be open neighbourhoods of $P$.
For $f\in\mathcal{O}(U)$ and $g\in\mathcal{O}(V)$ define $f \sim g$ if there exists a open neighbourhood $W\subseteq U\cap V$ of $P$ such that $f|_W=g|_W$. Then $\sim$ s an equivalence relation between these the set of all such pairs $(U,f)$. The set $\mathcal{O}_{P,Y}$ (or $\mathcal{O}_P)$ of all equivalence classes is a local ring, called the ring of germs of functions.
For a pair of functions $(U,f)$, $(V,g)$ (as above except we ignore a specific point $P$), define $f\sim'g$ if there exists a open set $W\subseteq U\cap V$ such that $f|_W=g|_W$. Then $\sim'$ is an equivalence relation and the set $K(Y)$ of all equivalence classes is a field.
Denote now with $K(R)$ the quotient field of an integral domain $R$.
I have to prove that in general the following is true:
$$\boxed{K(Y)=K(\mathcal{O}_P)}$$
We consider the restriction map $$\mathcal{O}_{P,Y} \to K(Y)\quad\text{defined as}\quad [f]\mapsto [f]'.$$
I have shown that this map is injective, then results that $$K(\mathcal{O}_{P,Y})\subseteq K(Y).$$
For the opposite inclusion I was suggested to use the following:

Using the above facts, irreducibility of $Y$ and $$\color{red}{K(Y)=\bigcup_{Q\in Y}K(\mathcal{O}_Q)}$$


Question 1. Why is the expression in red true?

show that $$K(\mathcal{O}_Q)=K(Y)\quad\text{for each}\quad Q\in Y.$$

Could someone suggest me how to proceed? I have no idea how to deal with this inclusion. Thanks!

 A: For the 'red' part: Let $f/g\in K(Y).$ Since $g \notin I(Y)$, choose a point $Q\in Y$, such that $g(Q)\neq 0$. Then   $f/g\in K(\mathcal{O}_Q).$
For the rest: Let $Q\in Y$.  Let $f/g\in K(Y).$ If $g\neq 0$ in $\mathcal{O}_Q$, then you are fine as then $f/g\in K(\mathcal{O}_Q).$
If $g=0$ in $\mathcal{O}_Q$, then there is $h\in A(Y)-\mathfrak{m}_Q$ such that $hg=0$ in $A(Y)$. Thus $hg\in I(Y)$. But $h$ and $g$ both are not in $I(Y)$. Contradiction as $I(Y)$ is a prime ideal.
So we are done.
A: Question: "...show that $K(O_{Y,Q})=K(Y)$ for each $Q∈Y$."
Answer: If $A:=A(Y)$ and if $\mathfrak{p} \subseteq A$ is the prime ideal corresponding to $Q$, it follows since $A$ is an integral domain and since localization is "transitive" that there are isomorphisms
$$K(Y)\cong K(A) \cong S^{-1}(A_{\mathfrak{p}}):=K(A_{\mathfrak{p}}):=K(\mathcal{O}_{Y,Q})$$
where $S \subseteq A_{\mathfrak{p}}$ is the multiplicative set of non-zero elements.
Question: "Thanks. In general, what means that the localization Is transitive?"
Answer: If $A$ is a domain, $T:=A-\mathfrak{p}$ with $\mathfrak{p}$ a prime ideal and $S:=A-(0)$, it follows $T \subseteq S \subseteq A$. Let $\tilde{S}:=p(S) \subseteq T^{-1}A$ where $p: A \rightarrow T^{-1}A$ is the canonical map. There are canonical isomorphisms of rings
$$K(A) \cong S^{-1}A \cong \tilde{S}^{-1}(T^{-1}A) \cong K(A_{\mathfrak{p}}).$$
