writing database