is it necesary that an optically denser medium should posses greater mass density than optically rarer medium?
No it is not so. Don’t confuse optically dense and rare medium with the density of a medium. Eg. Optically oil is denser than water, although, water has more mass density than oil.