Method #primary_key? is not reused

The #primary_key? method has already been written to check the type is primary key or not. Modified the method li'l bit to reuse in other places.