Results 1 to 5 of 5

Thread: Primary keys

  1. #1
    Join Date
    Dec 2003
    Location
    York PA
    Posts
    11

    Angry Unanswered: Primary keys

    In a project I am working on, I have 2 tables that I must link. These tables are based on imported data that is beyond my control. There is a series of fields that would make an excellent primary key except the data is alphanumeric, i.e. 66925E100R00. Any thoughts out there to make this work?
    Many thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the primary key of a table can be any datatype at all, provided that it is unique and not null
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    To be perfectly honest, it is generally good practice to institute your own primary keys. If the external information is beyond your control, what happens if the third party completely changes their database schema and produces a duplicate record or a new key that's in an unexpected format? I have a strong personal preference to defining and utilizing your own internal primary keys and retaining the supplied key for reference purposes only.

    Nothing wrong with using theres aside from that, all my humble opinion.

  4. #4
    Join Date
    Nov 2003
    Location
    San Francisco, CA USA
    Posts
    59

    Make your own.

    Teddy's right. You should enforce data integrity for those fields you find if they are supposed to be unique, but the best idea is to create a new ID field - perhaps using using an autonumber data type. Use that as your primary key.

    That is unless the data you have imported consists of multiple tables already with their own foreign and primary keys.

    Magee

  5. #5
    Join Date
    Dec 2003
    Location
    York PA
    Posts
    11
    Well, first of all,Access help says: "You cannot create a primary key using columns with a text, ntext, image, or bit data type." and that is a cut and paste right from Access help, troubleshooting primary keys. As to making my own key field, I don't see how it would help with matching the 2 tables to each other. Any more ideas?

Posting Permissions

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