Can someone explain detonation vs pre ingintion

Trying to learn these correct terms.

My understanding goes as far as spark plug ignition too soon while piston is traveling upward creating directional conflict. Is this one cause of pinging? Pre ignition or detonation.......just don't know.

Clearly, I'm not an engine builder just wrenching on one.

Thanks for all ongoing assistance.