Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011
    Posts
    12

    Unanswered: Primary Keys and Foreign Keys

    I have the Tables Patient, Doctor, Treatment, Pat_Doc_Treat, and Schedule.

    Patient(patientNumb, SS, name, dateOfBirth, address, dateAdmitted, clinic)
    Doctor(doctorID, name, pagerNumb)
    Treatment(treatmentCode, desciption)
    Pat_Doc_Treat(patientNumb, doctorID, treatmentCode, date, comments)
    Schedule(doctorID, date, clinic, numbOfWorkHours)

    So...I know that the underlined attributes are the primary keys.
    But for some of them, I'm kind of confused to pose it as the foreign keys.

    Patient - patientNumb PRIMARY KEY
    Doctor - doctorID PRIMARY KEY
    Treatment - treatmentCode PRIMARY KEY
    Pat_Doc_Treat - (patientNumb, doctorID, treatmentCode, date) PRIMARY KEY
    patientNumb FOREIGN KEY REFERENCES Patient(patientNumb),
    doctorID FOREIGN KEY REFERENCES Doctor(doctorID),
    treatmentCode FOREIGN KEY REFERENCES Treatment(treatmentCode),
    date --> This is newly created in the table (no references)
    Schedule - (doctorID, date, clinic) PRIMARY KEY
    doctorID FOREIGN KEY REFERENCES Doctor(doctorID),
    date --> Does this reference to Pat_Doc_Treat(date) or it doesn't?
    clinic --> Does reference to Patient(clinic)? Since it isn't a primary key in that table, it shouldn't be, right?

    Thanks.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    please post DDL (CREATE TABLE) for all tables being discussed; including the PKs
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Sep 2011
    Posts
    75
    Hello,

    Please post your table structure with the keys defined or generate the script and paste it here

Posting Permissions

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