Separated database code