You know that sodium is a metal, chlorine is a non-metal, so they form a lattice structure of alternating Na+ and Cl- ions.
With S8, that only contains one element, sulfur, and it tells you that the formula is a molecule containing 8 sulfur atoms. They would be covalently bonded.
Sodium Nitrate - so the formula is NaNO3. You know that the nitrate ion is NO3-, and the sodium forms Na+, so you can see it is ionically bonded. The sodium, as a metal, wouldn't be part of a covalent molecule with the nitrate, although the nitrate part is covalently bonded.