They are figures of speech. Synecdoche is, in a sense, a sub-category of metonymy.
Metonymy means to use a word in order to express something else which is connected to the word's meaning in a relation either based on "container-contained", or "representative-symbol". In other words, you say "He drank the whole bottle", when you actually mean "He drank the whole content of the bottle". Another example, representative of the...representative-symbol category could be: "The White House announced...", which actually means "The President/The secretary/the government announced..."
Synecdoche (some grammarians don't make a distinction with metonymy) describes a metonymy with a whole-part relation. Example: "I got myself new wheels", means "I got myself a new car"