sodium chloride is an ionic compound. which is formed by the attraction of the oppositely charged particles and that's why there occurs strong forces of attraction this forms a hard crystalline solid. Sodium is a metal which involves metallic bonding which of course derh is weaker than the ionic bonding in sodium chloride.
Hope this helps :D