A chemical compound is made up of many identical molecules formed from atoms from more than one element, attached by chemical bonds. However, not all compounds are created equally. Different things happen to ionic compounds and covalent compounds when they dissolve in water.
TL;DR (Too Long; Didn't Read)
When ionic compounds dissolve in water they go through a process called dissociation, splitting into the ions that make them up. However, when you place covalent compounds in water, they typically do not dissolve but form a layer on top of the water.
Ionic vs. Covalent Compounds
Ionic compounds are molecules consisting of oppositely charged ions, which are ions with both negative and positive charges. Covalent compounds are non-metals bound together, made up of two electrons shared between two atoms. Ionic compounds have a high melting and boiling point, but covalent compounds have a comparatively lower melting and boiling point. This is because ionic compounds need a very large amount of energy to break their ionic bonds and separate the positive and negative charges. Because covalent compounds are made of distinct molecules that don’t mix with each other, they separate more easily. Sodium bromide, calcium chloride and magnesium oxide are examples of ionic compounds, while ethanol, ozone, hydrogen and carbon dioxide are examples of covalent compounds.
Ionic Compounds in Water
When ionic compounds dissolve in water, they break apart into the ions that make them up through a process called dissociation. When placed in water, the ions are attracted to the water molecules, each of which carries a polar charge. If the force between the ions and the water molecules is strong enough to break the bonds between the ions, the compound dissolves. The ions dissociate and disperse in solution, each ringed by water molecules to prevent reattachment. The ionic solution turns into an electrolyte, meaning it can conduct electricity.
Covalent Compounds in Water
When covalent compounds dissolve in water they break apart into molecules, but not individual atoms. Water is a polar solvent, but covalent compounds are usually nonpolar. This means covalent compounds typically don't dissolve in water, instead making a separate layer on the water's surface. Sugar is one of the few covalent compounds that does dissolve in water because it is a polar covalent compound (i.e., parts of their molecules have a negative side and a positive side), but it still doesn't separate into ions the way ionic compounds do in water. Oil is a non-polar covalent compound, which is why it doesn't dissolve in water.