Results 1 to 3 of 3

Thread: Sport Teams Database with age restrictions

Hybrid View

  1. #1
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Sport Teams Database with age restrictions

    If you need to display people of certain age when "age group" is selected you MAY define "age_group" table and associate it with "peoples" table by adding a foreign key to peoples table - (below is a sample relationship between two tables):

    age_group table:
    Age_Group_ID
    Description

    Peoples table
    [all fields that you need]
    Age_Group_ID (FK - one to many)

  2. #2
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Sport Teams Database with age restrictions

    I think I'd come at this from a slightly different direction from Rhino but only because I'm reading the problem slightly differently.

    It doesn't sound to me like you need an Age Group as such, you just need to know what the age range for each team is. And since there all called UnderX I suspect you actually just have a max age for each team.

    With that in mind I'd add a MaxAge column to Teams. When a team is selected you can then select the apropriate people records something like this:-
    Select Name, Surname
    From People
    Where DateAdd(Year, DateOfBirth, @MaxAge) < GetDate()

    (You would pass Max Age in as a parameter when they slected the team)

    The main difference between mine and RB's aproach is that mine is more "dynamic" which may be a good or a bad thing. RB's aproach requires you to run a regular update to move people from one Age Group to another as they age, mine doesn't. That means that mine will naturally return you people who are Under 15 right now. If that's what you want then I'd suggest it's the better aproach becuase it requires no maintenance.

    But with things like this a persons eligibility is often based on their age at the beginning of the year rather than their age right now. If that's the case then things aren't so clear. My aproach would require quite a complicated join whereas Rhino's simply requires an automatic update to run once a year to move people into the right age group for the coming year.

    Which is right really depends on your exact requirements.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width