Based on what you have described I see no reason to tie a persons
sports role to them directly, by doing something like what I suggest
below, you tie a person to a role only when they use that role (during
a game).  If you think about it, this represents real life a bit more
accurately.  I played soccer (GK, mid-fielder, and forward at times)
and refereed soccer, as well as played basketball (guard) at times.

GameRoster(model):
    gamerole = FK(GameRole)
    person = FK(People)

Game(model):
personnel = M2M(GameRoster)

This way the roles are flexible (someone could be a Referee in one
game, a goalkeeper in another game and a scorekeeper in another game)
You could even build GameProfiles that would allow you create
validated game rosters (A hockey profile would allow you to put in
goalkeepers but a Football profile would not, unless you are not in
the US in which case a Football profile would allow goalkeepers but
not quarterbacks), and you could limit the number of any given roles
allowed, i.e. minimum number of referees, maximum number of
placekickers, etc...

this implies that you decouple league-roles from application roles, i.e.

GameRole = sports position
AppRole = Application permission role

HTH,
-richard



On 4/28/08, phloopy <[EMAIL PROTECTED]> wrote:
>
> I'm trying to figure out how to solve a particular problem in my Model
> design.  If I'm trying to pound a nail with an old shoe or glass
> bottle (google "Pounding A Nail: Old Shoe or Glass Bottle?") feel free
> to suggest a different way to tackle the problem.
>
> I'm building a system that manages sports leagues, hockey is the first
> one I'm worried about but I intend it to be flexible enough for others
> as well.  There are three objects that are involved in this question:
>
> Person: represents anybody involved in the league, has many roles
> (that is, Person's role = models.ManyToManyField(Roles))
> Role: Any given person can be a number of roles in the app.  Some
> examples are roles used for scheduling, such as player (member of a
> team), ref (multiple refs assigned to each game), scorekeeper, goalie
> (for leagues with rotating goalies), but roles would also be used for
> permissions on the app itself, such as Admin, or News Editor, etc.
>
> I'm fine with it up to that point, but getting the people and roles
> related to scheduled games is causing me problems.
>
> Game: A game is many-to-many with Person (Game's people =
> models.ManyToManyField(Person)), but for any given person related to
> the game it must be specified what their role is for that game.  They
> cannot be both a player and a ref, for example.
>
> If I weren't using django models I'd create a intermediary triple join
> table, with fields for player, role, and game.  I can't conceive how
> to do such a thing with Django though, since the intermediary join
> tables are done behind the scenes with ManyToMany relationships and
> seem to support two way relationships only.
>
> Is there a way to accomplish this design with Django Models?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to