Silicates are composed of SiO2 molecules under differing conditions of temperature and pressure they form Quartz, Agate, chert, flint, chalcedony and other minerals all very hard.
Corundum is Al2O3 - emerald, ruby, aquamarine are forms of it, the colors are derived from chromium, titanium iron and vanadium.
Beryls are variations of (Be,Na,Li,Ce)3Al2Si6O18 are referred to as beryllium aluminum silicates
Beryllium, sodium, lithium and cesium
The functions of chemical bonds, crystalline structure, heat and pressure all effect "hardness".
Carbon is the only element in diamond and that is the only formula given for it. A diamond is essentially a giant carbon molecule. It is formed under great pressure.
That is a great simplification but should give a basis for continuing your inqiury.