Should one place a container structure in a model?
For example,
AModel {
List<BModel> listB;
}
In terms of OO this makes sense. But when working with models and databases will I run into problems as AModel and BModel have their own tables? For instance, when I get AModel from a database do I just leave listB empty, or in order to completely retrieve the object do I also get all of BModel objects that are associated with AModel? However, sometimes I might just want to get AModel and not the list of BModels referencing AModel. Right now, I am considering deleting the list from AModel. This would then better reflect the database schema in which AModel has a 1-to-many relationship with BModel. I feel that it would be a more elegant approach. What do you think?
Aucun commentaire:
Enregistrer un commentaire