There are three main types of rocks: sedimentary, metamorphic, and igneous. Sedimentary rocks form from the compression of sediments over time, metamorphic rocks form from changes to existing igneous or sedimentary rocks through heat and pressure, and igneous rocks form either underground from cooling magma or above ground from volcanic eruptions of magma. Each rock type can be further broken down into various sub-categories. Rocks have been used by humans for many purposes throughout history.