Using active record to manage database