Completing several db functions