Analogy is the comparion of two pairs by using as. The two things have the same relationship.
An analogy can also be mixed up with a simile where you also use as or like. A simile is a figure of speech that uses like or as to compare things but they do not have the same relationship.
Red as a rose. (an analogy)
She is like the sunshine. (a simile)