Ternary form

Ternary form, sometimes called song form, is a three-part musical form consisting of an opening section (A), a following section (B) and then a repetition of the first section (A). It is usually schematized as A–B–A. Prominent examples include the da capo aria "The trumpet shall sound" from Handel's "Messiah", Chopin's Prelude in D-Flat Major "Raindrop", (Op. 28) and the opening chorus of Bach's "St John Passion".
Simple ternary form.
In ternary form each section is self-contained both thematically as well as tonally (that is, each section contains distinct and complete themes), and ends with an authentic cadence. The B section is generally in a contrasting but closely related key, usually a perfect fifth above or the parallel minor of the home key of the A section (V or i); however, in many works of the Classical period, the B section stays in tonic but has contrasting thematic material. It usually also has a contrasting character; for example section A might be stiff and formal while the contrasting B section would be melodious and flowing.
Da capo aria.
Baroque opera arias and a considerable number of baroque sacred music arias was dominated by the "Da capo" aria which were in the ABA form. A frequent model of the form began with a long A section in a major key, a short B section in a relative minor key mildly developing the thematic material of the A section and then a repetition of the A section. By convention in the third section (the repeat of section A after section B) soloists may add some ornamentation or short improvised variations. In later classical music such changes may have been written into the score. In these cases the last section is sometimes labeled A’ or A1 to indicate that it is slightly different from the first A section.
Compound ternary or trio form.
In a trio form each section is a dance movement in binary form (two sub-sections which are each repeated) and a contrasting trio movement also in binary form with repeats. An example is the minuet and trio from Haydn's "Surprise Symphony". The minuet consists of one section (1A) which is repeated and a second section (1B) which is also repeated. The trio section follows the same format (2A repeated and 2B repeated). The complete minuet is then played again at the end of the trio represented as: . By convention in the second rendition of the minuet, the sections are not repeated with the scheme . The trio may also be referred to as a double or as I/II, such as in Bach's polonaise and double (or Polonaise I/II) from his second orchestral suite and his bouree and double (or Bouree I/II) from his second English Suite for harpsichord.
The scherzo and trio, which is identical in structure to other trio forms, developed in the late Classical and early Romantic periods. Examples include the scherzo and trio (second movement) from Beethoven's Symphony No. 9 and the scherzo and trio in Schubert's String Quintet. Another name for the latter is "composite ternary form".
Trio form movements (especially scherzos) written from the early romantic era sometimes include a short coda (a unique ending to complete the entire movement) and possibly a short introduction. The second movement of Beethoven's Symphony No. 9 is written in this style which can be diagrammed as 
Marches by John Philip Sousa and others follow this form, and the middle section is called the "trio". Polkas are also often in compound-ternary form.
Quasi compound form.
Occasionally the A section or B section of a dance like movement is not divided into two repeating parts. For example, in the Minuet in Haydn's String Quartet op. 76 no. 6, the Minuet is in standard binary form (section A and B) while the trio is in free form and not in two repeated sections. Haydn labeled the B section "Alternative", a label used in some Baroque pieces (though most such pieces were in proper compound ternary form).
Ternary form within a ternary form.
In a complex ternary form each section is itself in ternary form in the scheme of By convention each part is repeated and only on its first rendition: . An example are the Impromptus (Op. 7) by Jan Voříšek.
Expanded ternary forms are especially common among Romantic-era composers; for example, Chopin's "Military" Polonaise (Op. 40, No. 1) is in the form , where the A and B sections and C and D sections are repeated as a group, and the original theme returning at the end without repeats.