Both metaphor and metonymy are figures of speech used in analogy. A metaphor is considered a substitution of one concept with another while a metonymy associates one concept with another. Metaphors are expressions which show similarity between two things and metonymies are figures of speech which refer to a thing not by name but by an associated word. It is a relationship based on continuity. While a metaphor is a conceptual view which presents ideas as objects, a metonymy presents a salient connection between two concepts.
Metonymy is used frequently in writing. A common example is when a building is used metonymically to stand for the people who work in it. "The White House is worried about ...". It is not the building that is worried about something, but the people in it. This is an example of a conventional type of metonymy whose meaning can be easily understood. Unconventional metonymies are usually more obscure and can only be understood with reference to the context. "Steam irons never have any trouble finding roommates" was written by Erma Bombeck and means that the type of person who owns a steam iron will always be in demand as a roommate. In one definition, a metonymy is an aspect of something that stands for or comes to represent that thing as a whole.
Metaphors are examples of inter-domain mind mapping compared to the intra-domain thinking involved in creating metonymies. A metaphor is an expression based on similarity which can be used to define the relationship and the transference of that relationship between one thing, or set of things, to another. It is widely believed that the most common metaphors have their basis in a physical experience of the world. This experiential basis indicates an overlapping with metonymy. To have "cold feet" when used to mean to lose courage and fail to go through with something is a metaphor indicative of intra-domain mapping and so could be said to be metonymically based. It is not wholly metonymical, however, as in the example referring to the White House.
The connection between metaphor and metonymy can be a complicated one as they can interact in several ways as in the metonymy within the metaphor and the metaphor from the metonymy. In summary, there are four basic differences between metaphor and metonymy. Metaphor substitutes and metonymy associates. The former can be taken to indicate condensation and the latter displacement. Metaphor and metonymy suppress and combine ideas respectively and the first is based on similarity while the second is based on contiguity.