In MVC, MVVM, or MVP I typically have models that either put a heavy emphasis on using other models in conjunction to get the full set of data needed or that basically require joins to other tables (models). When I run into this I usually just extend the model's functionality like normal but will include a join to another table in new method I'm creating. What's tricky for me to sometimes decide is which model I should put this functionality/join in since it makes it dependent on something not specific to that model. Is there a better way of dealing with relationships when using patterns that utilize data models?
Here is some pseudo code to help illustrate what I mean with some active record mixed in:
public static void getAll() {
this.db("sometable").join("anothertable", "column", "=", "anothercolumn").select();
}
Now if the model was for sometable
I'm creating a dependency of sorts by joining to another table
in the method above. Now the model for sometable
also deals with anothertable
which would have its own separate model.