Ionic compounds are usually formed when a metal atom loses its valence electrons to a nonmetal. The metal atom becomes a cation and the nonmetal atom becomes an anion. Since each ion is oppositely charged, they will be attracted to one another and an electrostatic bond will form between them.In the picture below a positive sodium ion will be attracted to a negative chloride ion and a bond will form between both atoms.
When the ions bond together they form three dimensional array called crystal lattices as shown in the picture.
For an additional note on bonding with animations
Ionic compounds dissolve in water to form solutions that conduct electricity. Such a solution is called an electrolyte. Compounds that dissolve in water but do not conduct electricity are are nonelectolytes and such compounds are called molecular compounds. An common example of a molecular compound is sugar. Sugar is made up of carbon, oxygen and hdrogen all of which are not metals.
Ionic compounds are formed when electrons are lost by the metal and they picked up or gained by the nonmetal. This Bohr diagram shows the electron transfer.
In writting formulas you must keep track of how many electrons are lost & gained.
Each metal must loose all of its valence electrons. Nonmetals can only gain only those many electrons that fill its valence shell to eight.
In the diagram, sodium loses 1 electron to chlorine and its outer shell now has eight electrons. (error in diagram, add an extra electron when you print). Using the periodic table will help you determine the charge of the ion.
Sodium has 1 valence electron, therefore it can only lose 1 electron. Oxygen has 6 valence electrons, hence it can only accept exactly 2 electrons.
When sodium reacts with oxygen, two sodium atoms are needed for every one oxygen atom for the electrons to balance according to valence rules and the formula is Na2O.
The diagram shows the electron transfer from calcium to bromine
and the formula is CaBr2. Notice that the formula is just the count of all the atoms that you see in the diagram.
More formulas will be done in class.
Naming formula follows a few simple rules.