Maybe I can say something useful here. The main confusion seems to be how to find the sheaves/ideals/modules associated to multiples of divisors. As Martin Bright points out, symbolic power of a prime ideal is one way to find this, but there are others.

## Symbolic powers

Given a prime ideal $P \subseteq R$ (or an intersection of prime ideals $\cap_i P_i$) one can form $P^n$ for every $n$ (or $(\cap_i P_i)^n$). The elements of this ideal certainly vanish to order $n$ along $V(P)$ but perhaps surprisingly, there can be other elements that vanish to order $n$ as well.

As you have already pointed out, in your example $S$, the element $X$ vanishes to order 2 along $D$ even though it is not in $(X,Z)^2$ (I guess your statement about Zariski neighborhood's maybe handles this difference). The way this is handled via commutative algebra is via something called symbolic powers.

Let $R_P$ denote the localization of $P$. Note if $f \in R$ vanishes to order $n$ along $V(P)$ this means that $f \in (P R_P)^n$.

**Definition:** The *$n$th symbolic power of $P$* is defined to be $P^{(n)} = (P R_P)^n \cap R$. The *$n$th symbolic power of $\cap_i P_i$* is defined to be $\cap_i P_i^{(n)}$.

Alternately, one can write

$$P^n = \cap_i Q_i$$

where the $Q_i$ are a primary decomposition of $P^n$. Then there is a unique $P$-primary component of that intersection, say $Q_1$ (see a commutative algebra book). It follows that $P^{(n)} = Q_1$. One can do something similar for the $\cap_i P_i$.

Symbolic powers are still a very active area of study within commutative algebra. One particular area of study is when are they equal to ordinary powers? For instance, this is known if $P$ is defined by a regular sequence and a few more cases. See Eisenbud's book for some discussion (or search the arxiv for *symbolic power*).

**Example:** For fun, try computing the second symbolic power of $\langle x,y \rangle \cap \langle x,z \rangle \cap \langle y,z \rangle \in \mathbb{Q}[x,y,z]$. You will see it is also different from the square.

## S2-ification

Now suppose that our $P$ is (or $P_i$'s) are all height 1 and further suppose that $R$ is a normal domain.

As we mentioned, the reason that $P^n$ isn't equal to the symbolic power is that $P^n$ has some higher embedded primes in its primary decomposition.

Anyway, it's not hard to see that a finitely generated module $M$ is S2 if and only if it satisfies Hartog's phenomena (see the excellent answers by Sándor Kovács HERE). In other words, if $X$ is $\mathrm{Spec} R$, and $Z \subseteq X$ is of codimension 2, then $H^0(X, \tilde M) = H^0(X \setminus Z, \tilde M)$. Hence one can construct the S2-ification of a module by finding a sufficiently big codimension-2 subset $Z \subseteq X$ and computing $H^0(X, \tilde M)$.

Under the hypotheses above, the S2-ification of $P^n$ is exactly the symbolic power (choose as $Z$ the set where the embedded $Q_i$ vanish).

**Remark:** Of course, if you choose the $P_i$ like in the example at the end of the Symbolic power section, the S2-ification will just give you $R$ (since you could choose your $Z$ to be the $V(\cap_i P_i)$).

## Reflexification

Suppose again that our $P$ is (or $P_i$'s) are all height 1 and that $R$ is normal.

There is a functor from $R$-modules to $R$-modules

$$M \mapsto \mathrm{Hom}_R(\mathrm{Hom}_R(M, R), R)$$

which sends to its $R$-reflexification (note, one can also reflexify against the canonical module which can do something different in the non-normal case).

Anyway, it's not hard to see that $\mathrm{Hom}_R(\mathrm{Hom}_R(P^n, R), R)$ is S2 and in fact is equal to the S2-ification (note that in codimension 1, $P^n$ is principal, and so the reflexification operation does nothing).

## Divisor definition

The definition of Weil divisor that I like best (including in the non-normal case) is as follows. Note that this doesn't necessarily coincide with your definition of Weil divisor as a sum of height primes.

**Definition:** A *Weil divisor* on a Noetherian ring (frequently S2) $R$ is an S2 subsheaf of $K(R)$ that

- Agrees with $K(R)$ after localizing at every height-0 prime of $R$ and
- Is principal after localizing at every height 1 prime of $R$.

A Weil divisor is *Cartier* if it is principal. Given a Weil divisor $D$, we define $nD$ to be the S2-ification of $D^n$ and so define a divisor to be $\mathbb{Q}$-Cartier if $nD$ is Cartier.

Frequently the second condition is left out in the literature. One can also call such things *Weil-divisorial sheaves* or *Almost Cartier Divisors*.

**Caveat:** The definition I like working with is the one that works for my applications. This doesn't mean that it is the right definition for other applications, and so there are other definitions one can make too! (Hopefully they all coincide in the case of a normal domain $R$).

## References

There is a nice paper by Hartshorne *Generalized divisors in Gorenstein rings* and also see *Generalized divisors and biliason*, which addresses all this in greater generality than I described here. As mentioned, Eisenbud's book on commutative algebra also contains some of this information (especially the symbolic power stuff). From the point of view of the minimal model program, there is a chapter on this in *Flips and Abundance for Algebraic Threefolds*.