database class implementation