Final answer:
The formula MgH₂ represents an ionic compound, which is made up of Mg²⁺ and H⁻ ions.
Step-by-step explanation:
The formula that shows an ionic compound is MgH₂. Ionic compounds are formed from positive and negative ions that are held together by strong electrostatic forces known as ionic bonds. In the given options, MgH₂, which stands for magnesium hydride, consists of Mg²⁺ (magnesium) ions and H⁻ (hydride) ions. This combination of a metal cation and a nonmetal anion produces an ionic compound, which is characteristic of option A.