Adjustment of spin quantum number in ionic bond I would like to describe my problem with an example:
The spin of 11th electron of Na (Sodium) atom could be $\pm \tfrac 12$. Let's consider in this case it is $+\tfrac 12$.
The spin of 17th electron of Cl (Chlorine) atom could be $\pm \tfrac 12$. Let's consider in this case it is $+\tfrac 12$.
Now for the formation of NaCl, the direction of the magnetic field created due to the spin of one of the above-mentioned two electrons needs to change. Question: The spin of which of the mentioned electrons will change, and why?
 A: The spin describes the orientation of the electron in relation to the other electrons in an atom. For a better idea, it is said here that the spin can be oriented inward and outward to the nucleus.
And as you described, the first or the seventh electron of the second shell can be directed either outward or inward.  Both orientations are equal in sodium because it is the only electron in the shell. In chlorine, three pairs of electrons already exist in the shell and the seventh electron also existed in both spin orientations. If you need a more descriptive picture, think of the magnetic dipole of the electron, which is like a small bar magnet and which is always antiparallel to the spin.
The chemical bond between Na and Cl occurs when the spins of the electrons involved are both pointing toward their atomic nuclei, or both pointing away from them. Then happens what Pauli described with his principle.
In sodium, it is easy to flip the spin alignment of the electron. The electron is alone in its shell. In sodium a higher energy input is needed because it is already surrounded by 6 electron pairs. If the Na and Cl atoms move towards each other, they already have the appropriate alignment of the electrons and enter into the bond. Should Na and Cl meet with improper electron alignments, the Na electron could flip and then the bond would fit.
