database reading and writing works