josh.kodroff posted on Wednesday, May 16, 2007
Hey all. I have a case of nested aggregation: We have studies. Sites participate in studies, and raters participate at sites for a study. That gives us a database table structure of (only the relevant columns are shown):
Study: study_id
Site: site_id
Study_Site: study_site_id, study_id, site_id
Rater_Study_Site: rater_study_site_id, rater_id, site_id
(No suggestions on changing the database structure, please. It's non-negotiable.)
The study object already has a bunch of children (4 different kinds), so I can't really load up a study just to add sites to it. In addition, in our business model, editing the study is something only a project manager should really do. Lower level employees can add sites to the study and raters to the sites for the study. Both actions are virtually never done at the same time.
Therefore, the form that adds sites and raters to a study will be its own distinct form.
Here's what I'm thinking for my object model:
- Create a root, read-only study object. I already have a StudyInfo class for when I need to list Studies in a DGV for non-editing purposes. I could probably reuse it and add an additional factory method something like GetStudyInfoWithSites().
- Create a StudySite/List object that is a child of StudyInfo. I already have a SiteInfo class similar to the StudyInfo class. I could have a private SiteInfo inside my StudySite class in addition to a studyId field.
- Create a StudySiteRater/List object that is a child of StudySite. I already have a Rater class that has no children (therefore, no need for a RaterInfo class) which I would probably make a private member and expose its properties as read-only. My StudySiteRater will also have a private studySiteId field.
- For performance reasons (a Study may have over 100 Sites), I may have to break encapsulation and grab all of the StudySiteRaters in one fell swoop. This may not be such a big deal since these classes may not even need to be public, and even if they do, they will only be used on one form, and it's a small project - 3 developers.
What do you guys think of my design?
Thanks for any help you can provide.
JK