Results 1 to 2 of 2

Thread: Primary Key

  1. #1
    Join Date
    Apr 2004

    Unanswered: Primary Key

    In the database that i have i use an auto number as a primary key. The database links various tables with the primary key ensuring that the correct medical conditions go along with the correct personal details. i.e

    Patient number 3 is linked by the primary key to the patient 3's medical conditions.

    A problem arises however when a mistake is made so that a record in the personal details is created and a record is not created in the medical conditions i.e

    patient id 5 is created in personal details but a mistake is made and the information is deleted. The next record will automatically be patient id 6 and not five. This then means that patient id 6 will have id number 5 in medical conditions and therefore will not have the correct medical information.

    Can anybody help me with this problem as it is effecting the accuracy of my database


  2. #2
    Join Date
    Sep 2003
    The extremely Royal borough of Kensington, London
    Foreign Key constraints will solve the problem.

    TableA(id) Primary key(id);
    TableB(id) Foreign Key (id) References TableA(id);
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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