<u>Answer:</u> The chemical formula of barium hydroxide octahydrate is
and that of magnesium sulfate heptahydrate is 
<u>Explanation:</u>
Ionic compound is defined as the compound which is formed by complete transfer of electrons from one atom to another atom.
The atom which looses the electron is known as electropositive atom and the atom which gains the electron is known as electronegative atom. This bond is usually formed between a metal (carrying positive charge) and a non-metal (carrying negative charge)
These are usually formed when a metal reacts with a non-metal or a metal reacts with a polyatomic ion or a reaction between two polyatomic ions takes place.
Barium hydroxide octahydrate is formed by the combination of barium ions
and hydroxide ions 
There are 8 water of crystallization around the given compound.
The chemical formula of this compound is 
Magnesium sulfate heptahydrate is formed by the combination of magnesium ions
and sulfate ions 
There are 7 water of crystallization around the given compound.
The chemical formula of this compound is 