TITLE: Zeros and poles of rational functions on locally Noetherian schemes
QUESTION [5 upvotes]: Let $X$ be a locally Noetherian scheme and let $f$ be a rational function on $X$ (i.e. the equivalence class of a pair $(U,f)$, where $f \in \mathcal{O}_X(U)$ and $U$ contains the associated points of $X$, under obvious equivalence relation). 
While reading Vakil's notes I wondered how could we define poles of such a rational function. After some thought I came up with the following definition: I'd  say that a regular codimension one point $p$ is a pole if it's not in the domain of definition of $f$. If $X$ is also an integral scheme (or at least if all the stalks of $\mathcal{O}_X$ are integral domains, in which case we can cover $X$ with integral schemes), then this definition would coincide with the usual one, namely using the discrete valuation at $p$.
But there is something unnatural about my definition, since I was not able to relate the rational function with the discrete valuation on $\mathcal{O}_{X,p}$ and consequently was not able to determine the order of the pole. So I'd like to know if it's possible to define a meaningful notion of poles for rational functions on locally Noetherian schemes and how would it relate to my definition. By extension, consider the same question about zeros.

REPLY [4 votes]: To clarify on what hypotheses are needed to define zeros and poles:
If $X$ is a locally Noetherian scheme (not necessarily integral, or even reduced) and $p$ is a regular codimension $1$ point, we can define the order of vanishing of any non-zero $f$ in the fraction field of $\mathcal{O}_{X,p}$ using the discrete valuation corresponding to this dimension one regular local ring. It is really important to be able to do this in generality, since you want to be able to consider rational sections of line bundles on non-integral schemes, and to use Hartogs lemma to extend rational sections to regular sections to be able to properly develop the theory of Weil divisors on non-integral schemes.
In particular, if $X$ is a locally Noetherian scheme regular in codimension $1$ (for example, if $X$ is locally Noetherian and normal), we can define what it means for any rational function $(f,U)$ on $X$ to have a zero or pole of some order at any codimension one point, without any other conditions on $X$ (i.e. $X$ need not be integral, or even reduced). Note that what we really need to do is take the data $(f,U)$ and get an element of the fraction field of $\mathcal{O}_{X,p}$.
To do this, note that (as in the answer by "TTS") we can take any affine open subscheme about $p$ which, by exercise $5.4.B$ of Vakil, is a disjoint union of integral Noetherian normal schemes. We can then take the component of this decomposition containing $p$ (which is then isomorphic to $\rm{Spec}(A)$ for some Noetherian integral domain A) and note that $f$ restricts to a rational function on this open subscheme, which will then correspond to an element of the fraction field of $\mathcal{O}_{X,p}\cong A_p$ and so we can talk about zeros and poles as usual. We could also (again, as pointed out by "TTS") use the fact that the minimal primes of $\mathcal{O}_{X,p}$ correspond to irreducible components of $X$ containing $p$, which then implies (since $\mathcal{O}_{X,p}$ is an integral domain) that $p$ is contained in a unique irreducible component. Since $U$ contains all associated points, it contains the generic point $\eta$ of this component. Since $\mathcal{O}_{X,\eta}$ is the fraction field of $\mathcal{O}_{X,p}$ and we can take the stalk of $f$ at $\eta$, we can obtain an element of the fraction field of $\mathcal{O}_{X,p}$ from $f$ and so talk about zeros and poles of $f$ using this.