RPM is a little like windows — it’s chaotic, and if it’s disturbed everything blows up and there’s nothing you can do. But, if you find that rpm suddenly stops working and none of the commands work, try doing:
rm -f /var/lib/rpm/__db*
and it might just work again. As always, you should have backups.