We know that a personality disorder is a way of relating to the world at large that constantly leaves us and the people around us feeling uncomfortable, shortchanged or downright unsafe.
Narcissistic personality disorder comes from a way of relating that we learn to make up for a fundamental lack of self esteem growing up. Because our sense of self is not stable, we try to have it stabilized by seeking the admiration of others around us.
This can lead to compulsive grandiosity or showboating, and also in the putting down of other people. In the former case, we feel better with admiring eyes on us, in the latter we feel better about our lack of self-esteem by demeaning another person.