refactoring model code using flask-sqlalchemy full feature.