Both Sodium and Magnesium have third electron shell 3s as their outermost valence electrons, therefore they are in the same period. This period corresponds to the accumulation of electrons in the third (n = 3) shell, especially its 3s and 3p subshells, in a quantum mechanical explanation of atomic structure.