HI Ben Lim.
Nikon lenses have 5 types or generations.
Beginning with the latest to the oldest. AF-S, AF-D, AIS, AI, PRE AI.
AF-S lenses, the AF motor is built in the lens, the motor is an ultrasonic wave motor (Sonic Wave Motor). All Nikon D series camera body support this lens type.
AF-D lenses, the lens focus with a screw drive coupling from the camera body. The AF motor is in the camera body. Semi pro and pro bodies all have this motor in the camera body.
AIS and AI lenses can be used on camera that support manual focus lenses, just enter the lens focal length and aperture value in the camera menu and it will work with matrix metering, D5100 doesnt support this function. The D7000 and D7100 can support AI and AIS lenses.
PRE AI lenses are very ancient lenses that can only be used on the camera body without the aperture index ring. Nikon F, F2 body. Never mount PRE AI lenses on bodies with a aperture index ring..
So for the D5100 you will have no problem using any AF-S FX lenses but for the AF-D lenses, you can use it too but will need to focus it manually because the D5100 doesnt have a built in screw drive focus motor.