In this paper a design approach for Zinc Oxide (ZnO) based p-i-n structure photodiode is demonstrated for ultraviolet (UV) detection. The peak sensitivity occurs at a range of 320nm to 340nm. The detection range can be further decreased by suitably alloying ZnO with MgO. Rigorous theoretical investigation has been performed for the device optimization to improve the responsivity. The optimization involves doping concentration and thickness calibrations of various constituent layers of the device. These results indicates that ZnO based photodetectors are good candidates for detecting ultraviolet radiation.