Ring of rational functions for reducible variety Let $X$ be some affine algebraic variety over $\mathbb{k}$ (i.e. some closed subset in $\mathbb{A}_\mathbb{k}^n$). First suppose $X$ to be irreducible. Then the algebra $\mathbb{k}[X]$ is a domain and we can consider the field of rational functions $\mathrm{Quot}_{\mathbb{k}[X]}=\mathbb{k}(X)$. Could you explain me how to build an analogue of this field in the case when $X$ is not necessarily irreducible? Then $\mathbb{k}[X]$ must not be a domain and we are to build some kind of localization?
Also, what is the destination of rational functions? Why we cannot be satisfied with only regular maps and regular functions?
 A: The analogue of the quotient field for a ring with zero divisors is the total ring of fractions: basically, just invert everything that is not a zero divisor. Geometrically, an element of this ring can be viewed as a collection of rational functions, one on each irreducible component of $X$, such that they coincide on intersections.
Rational functions are important for a wide variety of reasons. Asking this question is like asking why $\mathbf Q$ is important. Why weren't we happy with $\mathbf Z$? Well, it wasn't big enough for what we wanted to do, so we enlarged it.
A: This question may have general interest. There is an exercise in Matsumura (exercise 9.11 page 70) saying the following:
Let $A$ be a noetherian ring with the propery that $A_{\mathfrak{p}}$ is a domain for all prime ideals $\mathfrak{p}$. Let $\mathfrak{p}_1,..,\mathfrak{p}_l$ be the minimal prime ideals of $A$. It follows there is an isomorphism of rings
I1. $p:A \cong A/\mathfrak{p}_1\oplus \cdots \oplus A/\mathfrak{p}_l:=A_1\oplus \cdots \oplus A_l$
defined by
$p(a):=(\overline{a}, ..., \overline{a})$. This gives at the level of schemes an isomorphism
$Spec(A) \cong Spec(A_1) \cup \cdots \cup Spec(A_l)$
where the union is the "disjoint union".
This gives a general formula for the total ring of fractions $Tot(A)$:
I2. $Tot(A)\cong K(A/\mathfrak{p}_1)\oplus \cdots \oplus K(A/\mathfrak{p}_l)$
where $K(A/\mathfrak{p}_i)$ is the quotient field of the integral domain $A/\mathfrak{p}_i$.
Question: "Then k[X] must not be a domain and we are to build some kind of localization?"
Answer: The "total ring of fractions" is defined on page 21 in Matsumura's book "Commutative Ring Theory". This is a construction generalizing the "quotient field" defined for integral domains. If the ring $k[X]$ satisfies formula I1, it follows I2 gives a general formula for $Tot(k[X])$.
PS: I have not done the exercise myself.
