Question: I studied the solubility of compounds in water. I have found that [calcium carbonate](http://en.wikipedia.org/wiki/Calcium_carbonate) doesn't dissolve in water. The teacher stated that the ionic compounds dissolve in water except some carbonates. What would be a clear elaboration of this phenomenon?

Answer: 
For an ionic substance to dissolve in water, there are two competing factors that determine the enthalpy of solution $\Delta{H}\_\mathrm{sol}$ which is the enthalpy (energy) change when a solute is dissolved in a solvent:

1. The lattice energy (LE), the energy of formation of the crystal between infinitely separated ions. As LE is proportional to the charges of its ions, for calcium carbonate, its LE would be roughly 4× the LE of sodium chloride. $$\ce{CaCO3 (s) -> Ca^2+ (g) + CO3^2- (g)}$$ This value is always positive, as energy is required to separate the ions.
2. The hydration energy of gaseous ions, which is the enthalpy change when gaseous ions dissolve in sufficient water to give an infinitely dilute solution. $$\ce{Ca^2+ (g) + CO3^2- (g) -> Ca^2+ (aq) + CO3^2- (aq)}$$ These values are always negative, as energy is released upon hydration of ions.

As the LE of calcium carbonate is so large, a great amount of free energy would be required to break the strongly attracted ions apart, and this energy has to come from the enthalpy of hydration. In the case of calcium carbonate, the enthalpy of hydration is not large enough to overcome the large lattice energy, hence it exists as a solid.

Do note that solubility of ionic compounds are not absolute. In fact, solubility in water is often given as a value in g/L of water. 

However, generally, we define solubility as:

1. Soluble substances can form a 0.1 M solution at 25 °C.
2. Insoluble substances cannot form a 0.1 M solution at 25 °C.
Solubility of salts is not a prediction that I like to make. It all comes down to $\Delta{G}\_{sol} < 0$. That condition is fulfilled when $\Delta{H}\_{sol} < 0$ and $T \Delta{S}\_{sol} > 0$ or one factor outweighs the other.

There's two problems. Lattice enthalpies are large, as are solvation enthalpies, and the common observation is that $\Delta{H}\_{sol}$ in most cases is small. We are calculating differences of large numbers, and the one fact we can confidently assert is that the difference is impossible to predict and generally meaningless.

Same thing for $\Delta{S}\_{sol}$. Lattice entropies are small, but entropies of solution are lower than one would think thanks to the short-range order the solvated cation imposes on the solvent. You are gaining translational entropy from dissolving the lattice and losing translational entropy from the solvent through the inner coordination shell. You are calculating differences of numbers of equal magnitude again, and just by staring at reagents it's impossible to tell which way the pendulum is going to swing and if the result is positive or negative.