The difference between covalent compounds ad iconic compounds is that in covalent bonding electrons are shared rather than transferred between one another, and in iconic bonding the electrons are transferred. Covalent compounds are formed between two non-metals, and iconic compounds are formed between a metal and a non-metal.
MgSO4 - iconic (magnesium is a metal, SO4 is a non-metal), and covalent (S and O are non-metals)
NH3 - covalent (N and H are non-metals)
CHCL3 - covalent (C, H, and, Cl are non-metals)
Br2 - covalent (Br is a non-metal)
CaCL2 - iconic (Ca is a metal, Cl is a non-metal)
SO2 - covalent (S and O are non-metals)