s4:kdc move db functions in their own file