Thread: Foreign Keys

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    6
    Rep Power
    0

    Foreign Keys


    Hi my question is to do with football tables. Ive read most of the post relating to this. I have a results table which I pull the data from a csv file, which already has the data i need. The columns are - date, home team, away team, home result, away result, and a few more. From what i've read, the view seems to be to have a team table with unique ids, there division etc. If my data already has the team names in before i pull it to my results table, am i best to change the team names to the team ids from the team table. im thinking yes, but cant decide if its because its easier to query with sql or its not good pratice to have the same information in two tables.
    Regards Robert
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    whether you want to use team ids instead of team names depends entirely on the source csv file

    if the csv file is under your control, then yeah, you could replace the names with ids

    although, to be honest, it's a lot easier to make a typo (e.g. 13 instead of 23) that will not be obvious (if both 13 and 23 are valid numbers)

    however, for the sake of getting the teams right, a typo in the team name (e.g. cincinnati bungles) is not as crucial
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    6
    Rep Power
    0
    Thankyou for your reply.

IMN logo majestic logo threadwatch logo seochat tools logo