Compounds are referred to as 'ionic' or 'covalent' depending on the type of bonding that they exhibit.
In ionic bonding, a transfer of electrons from one atom to another creates two ions with opposing electric charge. This transfer is generally from a metal to a non-metal. Metal atoms that lose electrons become cations, and non-metal atoms that obtain electrons become anions. Electrostatic attraction between the ions of opposite charge holds them together.