A compound is a molecule made of atoms from different elements. All compounds are molecules, but not all molecules are compounds. Hydrogen gas (H2) is a molecule, but not a compound because it is made of only one element. Water (H2O) can be called a molecule or a compound because it is made of hydrogen (H) and oxygen (O) atoms.
There are two main types of chemical bonds that hold atoms together: covalent and ionic/electrovalent bonds. Atoms that share electrons in a chemical bond have covalent bonds. An oxygen molecule (O2) is a good example of a molecule with a covalent bond. Ionic bonds occur when electrons are donated from one atom to another.