implement model and database