implement databse layer and test