Look at the periodic table to find the charge on atoms. Magnesium is +2 and Nitrogen is -3. Since there are two nitrogen charge 2*-3 = -6 there needs to be 3 Mg then (3*2+ = 6+) to pair with the two nitrogen. 3 Mg(+2) + 2 N(-3) = Mg3N2
The primary structure of a protein refer to the amino acid sequence. The secondary structure of a protein refer to the alpha helices, beta sheets and turns, while the tertiary structure refer to folding of the sheets due to hydrogen bonding or other bonding interaction between them.