The elements in the periodic table are arranged in order of atomic number, which is also called proton number. They are also arranged so that elements with similar properties line up in columns. These columns are called groups. The table is called a periodic table because similar properties occur at regular intervals.
Elements in the same group have the same number of electrons in their outer shell, and this gives them similar chemical properties. Magnesium (2,8,2) and calcium (2,8,8,2) are both in Group 2 because each has two outer electrons. Lithium (2,1) and sodium (2,8,1) are both in Group 1 because each has one outer electron.
The rows of the table are called periods, and the number of the period is the number of shells that contain electrons. Sodium has three occupied shells, so it is in period 3. Knowing the group lets you predict how an element will react: potassium is in Group 1 like sodium, so it reacts in a similar way.