0

For my homework I have to develop the sql code for the chart in the picture but for the doctor relation how can I show candidate keys? is there a special way of declaring?

CREATE TABLE "Doctor" (
    "DoctorID"  INTEGER NOT NULL,
    "Superviosr"    TEXT,
    "Name"  TEXT,
    "Phone" INTEGER,
    "SpecialtyNumber"   INTEGER,
    PRIMARY KEY("DoctorID")
);

doctor

Sina Cengiz
  • 136
  • 1
  • 8
  • 1
    Candidate keys are columns that could be promoted to primary key. There is no specific way to designate them in sql. However, by their nature they must be unique, so you could always specify a unique index on them. – Honeyboy Wilson Mar 03 '20 at 17:51
  • Thank you very much so by declaring them unique will solve my problem – Sina Cengiz Mar 03 '20 at 18:45
  • Exactly what problem are you trying to solve? I don't see any possible candidate keys in your Doctor table, do you? – Honeyboy Wilson Mar 03 '20 at 19:07
  • According to what we learned so far in the course, in ER diagrams the attributes with in bold are primarykeys, the attributes that start with black dot are candidate keys and attributes with dot (but not filled inside like email) are non key attrbibutes – Sina Cengiz Mar 04 '20 at 06:07
  • In your Doctor table for example, how could name be a candidate key? Two doctors could have the same name. How could SpecialtyNumber be a candidate key? Two doctors could be in the same specialty. Etc. Two doctors in the same office could share a phone number so it couldn't be a candidate key. Where do you see any candidate keys in the Doctor table? – Honeyboy Wilson Mar 04 '20 at 14:43

0 Answers0