improved database and model relations