Answer:
See below.
Step-by-step explanation:
Method 1:
You know that oxygen is a non-metal.
If the compound is ionic, the oxygen must be combined with a metal.
The Mg must be a metal.
Method 2:
In the formulas of ionic compounds, the positive ion (usually a metal) is written first.