Finished database code