Nikor 50mm F/1.8G or 50mm F/1.8D?

I'm new in photography and planning to buy Nikon D5200 this month. So looking for a prime lens. I'm confused between 50mm f 1.8 D & G. I know the G is the newer lens & costs higher than D, but not quite sure what the difference is between the two. Nikon says G has automatic focus. I think G is better because it is newer. Is there any significant image quality difference between these two.
I want to buy prime lens for low light images, so can anyone explain and recommend one over the other.

The lens you need for your new D5200 is ANY Nikkor AF-S lens, whether it has a G or D behind its description.

As long as the lens is an AF-S model it will auto focus on your D5200. Nikon's AF lenses can be used on your D5200 but will not auto focus. So buy the AF-S model.