finish some incomplete database code