Edit (11/12/12): I added an explanation of the phrase "this is essentially equivalent to X being S2" at the end to answer aglearner's question in the comments.
[See also here and here]
Dear Jesus,
I think there are several problems with your question/desire to define a canonical divisor on any algebraic variety.
First of all, what is any algebraic variety? Perhaps you mean a quasi-projective variety (=reduced and of finite type) defined over some (algebraically closed) field.
OK, let's assume that X is such a variety. Then what is a divisor on X? Of course, you could just say it is a formal linear combination of prime divisors, where a prime divisor is just a codimension 1 irreducible subvariety.
OK, but what if X is not equidimensional? Well, let's assume it is, or even that it is irreducible.
Still, if you want to talk about divisors, you would surely want to say when two divisors are linearly equivalent. OK, we know what that is, D1 and D2 are linearly equivalent iff D1−D2 is a principal divisor.
But, what is a principal divisor? Here it starts to become clear why one usually assumes that X is normal even to just talk about divisors, let alone defining the canonical divisor. In order to define principal divisors, one would need to define something like the order of vanishing of a regular function along a prime divisor. It's not obvious how to define this unless the local ring of the general point of any prime divisor is a DVR. Well, then this leads to one to want to assume that X is R1, that is, regular in codimension 1 which is equivalent to those local rings being DVRs.
OK, now once we have this we might also want another property: If f is a regular function, we would expect, that the zero set of f should be 1-codimensional in X. In other words, we would expect that if ZsubsetX is a closed subset of codimension at least 2, then if f is nowhere zero on XsetminusZ, then it is nowhere zero on X. In (yet) other words, if 1/f is a regular function on XsetminusZ, then we expect that it is a regular function on X. This in the language of sheaves means that we expect that the push-forward of mathscrOXsetminusZ to X is isomorphic to mathscrOX. Now this is essentially equivalent to X being S2.
So we get that in order to define divisors as we are used to them, we would need that X be R1 and S2, that is, normal.
Now, actually, one can work with objects that behave very much like divisors even on non-normal varieties/schemes, but one has to be very careful what properties work for them.
As far as I can tell, the best way is to work with Weil divisorial sheaves which are really reflexive sheaves of rank 1. On a normal variety, the sheaf associated to a Weil divisor D, usually denoted by mathcalOX(D), is indeed a reflexive sheaf of rank 1, and conversely every reflexive sheaf of rank 1 on a normal variety is the sheaf associated to a Weil divisor (in particular a reflexive sheaf of rank 1 on a regular variety is an invertible sheaf) so this is indeed a direct generalization. One word of caution here: mathcalOX(D) may be defined for Weil divisors that are not Cartier, but then this is (obviously) not an invertible sheaf.
Finally, to answer your original question about canonical divisors. Indeed it is possible to define a canonical divisor (=Weil divisorial sheaf) for all quasi-projective varieties. If XsubseteqmathbbPN and overlineX denotes the closure of X in mathbbPN, then the dualizing complex of overlineX is
omegaboverlineXullet=RmathscrHommathbbPN(mathscrOoverlineX,omegamathbbPN[N])
and the canonical sheaf of X is
omegaX=h−n(omegaboverlineXullet)|X=mathscrExtN−nmathbbPN(mathscrOoverlineX,omegamathbbPN)|X
where n=dimX. (Notice that you may disregard the derived category stuff and the dualizing complex, and just make the definition using mathscrExt.) Notice further, that
if X is normal, this is the same as the one you are used to and otherwise it is a reflexive sheaf of rank 1.
As for your formula, I am not entirely sure what you mean by "where the Di are representatives of all divisors in the Class Group". For toric varieties this can be made sense as in Josh's answer, but otherwise I am not sure what you had in mind.
(Added on 11/12/12):
Lemma A scheme X is S2 if and only if for any iota:ZtoX closed subset of codimension at least 2, the natural
map mathscrOXtoiota∗mathscrOXsetminusZ is an isomorphism.
Proof
Since both statements are local we may assume that X is affine.
Let xinX be a point and ZsubseteqX its closure in X. If x is a codimension at most 1 point, there is nothing to prove, so we may assume that Z is of codimension at least 2.
Considering the exact sequence (recall that X is affine):
0toH0Z(X,mathscrOX)toH0(X,mathscrOX)toH0(XsetminusZ,mathscrOX)toH1Z(X,mathscrOX)to0
shows that mathscrOXtoiota∗mathscrOXsetminusZ is an isomorphism
if and only if
H0Z(X,mathscrOX)=H1Z(X,mathscrOX)=0 the latter condition is equivalent to
mathrmdepthmathscrOX,xgeq2,
which given the assumption on the codimension is exactly the condition that X is S2 at xinX. qquadsquare