What is the difference between synecdoche and metaphor?

Synecdoche and metaphor are both types of figures of speech, but they operate in different ways.

While synecdoche replaces a whole with one of its parts (e.g., “heads” to refer to people), a metaphor makes a comparison between two unrelated things (e.g., “he is an open book”).

With synecdoche, there is a literal relationship between the whole and its part that serves as a stand-in. With metaphor, the relationship between the two things being compared is less direct.