reduce db common code

reduce db common code