<p>I'm trying to find the best design for the following scenario - an application to store results of dance competitions. </p>

<p>An event contains multiple rounds, each round contains a number of performances (one per dance). Each performance is judged by many judges, who return a scoresheet.</p>

<p>There are two types of rounds, a final round (containing 6 or less dance couples) or a normal round (containing more than 6 dance couples). Each requires slightly different behaviour and data. </p>

<p>In the case of a final round, each scoresheet contains an ordered list of the 6 couples in the final showing which couple the judge placed 1st, 2nd etc. I call these placings "a scoresheet contains 6 placings". A placing contains a couple number, and what place that couple is</p>

<p>In the case of a normal round, each scoresheet contains a non-ordered set of M couples (M &lt; the number of couples entered into the round - exact value determined by the competition organiser). I call these recalls: "a score sheet as M recalls". A recall does not contain a score or a ranking</p>

<p>for example
In a final</p>

<ul>
<li>1st place: couple 56 </li>
<li>2nd place: couple 234 </li>
<li>3rd place: couple 198 </li>
<li>4th place: couple 98 </li>
<li>5th place: couple 3</li>
<li>6th place: couple 125</li>
</ul>

<p>For a normal round
The following couples are recalled
54,67,201,104,187,209,8,56,79,35,167,98</p>

<p>My naive-version of this is implemented as</p>

<p>Event - has_one final_round, has_many rounds</p>

<p>final_round - has_many final_performances
final_performance - has_many final_scoresheets
final_scoresheet - has_many  placings</p>

<p>round - has_many perforomances
performance has_many scoresheets
scoresheet has_many recalls</p>

<p>However I do not like the duplication that this requires, and I have several parallel hierarchies (for round, performance and scoresheet) which is going to be a pain to maintain.</p>

[{'answer_id': 63178, 'author': 'Jim Kiley', 'author_id': 7178, 'author_profile': 'https://Stackoverflow.com/users/7178', 'pm_score': 2, 'selected': False, 'text': "<p>This requires a little domain knowledge that I don't have, but it seems to me that the ordered vs. non-ordered situation is a little bit irrelevant.  If each couple has a score, the ordering in the final round can be deduced from each couple's score, right?  That would mean that the final round's data structure would be like every other round's data structure, consisting of multiple (couple, score) sets.</p>\n"}, {'answer_id': 321177, 'author': 'DJClayworth', 'author_id': 19276, 'author_profile': 'https://Stackoverflow.com/users/19276', 'pm_score': 0, 'selected': False, 'text': "<p>Without knowing in detail what is going on it's hard to give clear advice. However based on what I read it seems your parallel hierarchy may not be necessary. </p>\n\n<p>It's not clear that a final_performance is really different from a performance. I guess they are scored differently; that should be reflected in differences in final_scoresheet, and you probably assumed that you needed to make final_performance different because it had to contain final_scoresheets. Maybe you could have only one performance object, and rather than having the scoresheets contained in the performance have the round object associate scoresheets with performances:</p>\n\n<pre><code>round.getScoresheet(couple,dance)\n</code></pre>\n\n<p>rather than</p>\n\n<pre><code>round.getPerformance(couple,dance).getScoresheet()\n</code></pre>\n\n<p>I also wonder if you need objects for placings and recalls: can they just be (ordered) lists of couples retrieved from the scoresheets? If so then you've eliminated three classes.</p>\n\n<p>Containment is preferred over inheritance.</p>\n"}]
['https://Stackoverflow.com/questions/63125', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7473/']