move db-specific bits to helper classes