Realism is a generic position that philosophers often apply to certain thing but not others. That is, most philosophers are realists with respect to some things but anti-realists with respect to other things. For example, one can believe that physical objects are real but abstract objects are not, or one can believe that distributed wholes are real but sets are not.
In general to say that a class of objects is real is to say that objects of that class exist on their own and are not to be explained by or reduced to other objects. A realist is one who claims, with respect to some class, that objects of that class are real. An anti-realist claims the opposite.
The difference between a realism debate and an existence debate is that in a realism debate, both sides agree that the class of objects under discussion exists in some sense or at least that most common propositions about the objects are true, but they differ on how to account for the objects. That is, they are not arguing over the truth of statements about the objects, but about what underlies those statements. For example, someone who is not a realist with respect to mathematical objects could still claim that mathematics is true, but someone who denies the existence of God would not generally say that common statements about God are true. Thus, there are mathematical realists but not God realists. The debate about God is an existence debate, not a realism debate.
The most general contrast is not between realist and idealist but between realist and reductionist. A reductionist is someone who claims, for some general class of objects, that objects of that class are really something else. For example, some philosophers have claimed that the objects of mathematics are really just marks on paper, that mathematics is just a game played with symbols (this position is sometimes called nominalism, but should more properly be called formalism).
In some of the most important debates, the reductionists are idealists; that is, they try to reduce the objects under consideration to ideas, mental events. There is an idealist account of mathematical objects in which mathematical objects are viewed as ideas in the head rather than abstract objects.
The most well-known realist/idealist debate is that with respect to the physical world. A realist with respect to the physical world is someone who claims that at least some physical objects (or at least physical fields or events) are real and are not to be explained in terms of anything non-physical. An idealist is one who reduces all physical objects and events to the subjective impressions or sensations that we receive from them.
In the debate over the physical world there isn't any commonly held third opinion, so in this debate, realism and idealism are often treated as the only two possibilities.