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?

-

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.

-
Thank you, Bruno Joyal! So, the rational function can be undefined at some points, isn't it? How we can describe the set where it can be defined? –  user74574 Dec 5 '13 at 21:32
You are welcome @Nikita. Well, they are defined: they take the value $\infty$. The points where they are finite could be called the "regular locus" or something like that. What kind of description would you like the set to have? –  Bruno Joyal Dec 5 '13 at 21:36
I meant the intersections of "regular locus" with irreducible components. In fact, I'd like to understand if the intersections can be empty... –  user74574 Dec 5 '13 at 21:40
@Nikita No, they cannot. I've added a precision to my post! –  Bruno Joyal Dec 5 '13 at 21:43
Could you explain this piece briefly? –  user74574 Dec 5 '13 at 21:48