Zeros and poles of rational functions on locally Noetherian schemes 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.
 A: 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.
A: Here's how I think this works. Take a codimension $1$ point $p$. The irreducible components containing $p$ correspond to minimal primes of $\mathcal{O}_{X,p}$ and there's only one of these. Let's say the generic point for it is $\eta$. Then there is an inclusion $\mathcal{O}_{X,p} \to \mathcal{O}_{X,\eta}$ which is just taking the fraction field. Your $U$ has to contain $\eta$, so you can take the stalk of $f$ there and then find its valuation at $p$.
It's confusing. It's probably good to note that around any point you can find a Noetherian open subscheme, and then this is a finite disjoint union of Noetherian normal irreducible schemes, which is what you really like.
A: I don't understand the problem. A $1$-dimensional regular noetherian local ring is a discrete valuation domain (yes, it's automatically an integral domain), so you can take the discrete valuation of the germ $f_p \in \mathcal{O}_{X,p}$ as the definition of the order of $f$ at $p$. Actually this is the usual definition.
A: The order of vanishing of a rational function is only defined on locally noetherian, integral schemes, at points of codimension 1.  The locally noetherian and codimension 1 conditions are to ensure that the order is finite, and that the maps $\mathrm{ord}_x : R(X) \to \mathbf{Z}$ are homomorphisms; see (Stacks, Comm. alg., Orders of vanishing).  And the integrality assumption is so that rational functions correspond to elements of the fraction fields of stalks; otherwise as you see yourself the definition doesn't work at all.
In practice this doesn't really present a problem.  For example when considering Weil divisors (1-codimensional cycles) associated to rational functions, if one has a Weil divisor associated to a rational function on a closed integral subscheme Z of X, one can consider the direct image of this cycle by the inclusion, to get a cycle on X.  (This is how one defines rational equivalence of cycles.)
