0
CREATE TABLE doctor_schedule (
 doctor_id int(11) NOT NULL,
 attention_time_slot_id int(11) NOT NULL,
 available tinyint(1) NOT NULL DEFAULT '1',
 date date NOT NULL,
 PRIMARY KEY (doctor_id,attention_time_slot_id,date),
 FOREIGN KEY (doctor_id) REFERENCES doctor (id),
 FOREIGN KEY (attention_time_slot_id) REFERENCES attention_time_slot (id)
)
2
  • 1
    Mira Cómo preguntar <- ACA para que tu pregunta sea mejor recibida. También, aprovecha y haz el recorrido de bienvenida <- ACA para entender mejor cómo funcionamos y de paso obtener tu primera medalla! Deberias mostrar las tablas relacionadas a ver si hay algun problema con ellas. Este create es correcto sintactimante.
    – gbianchi
    el 19 may. 2018 a las 22:07
  • agrega todas las tablas involucradas en la creación de dichas llaves foráneas
    – user75901
    el 20 may. 2018 a las 0:03

1 respuesta 1

0

Creo que deberia ser de la siguiente manera:

CREATE TABLE doctor_schedule (
 doctor_id int(11) NOT NULL,
 attention_time_slot_id int(11) NOT NULL,
 available tinyint(1) NOT NULL DEFAULT '1',
 date date NOT NULL,
 CONSTRAINT pk_doc_schedule PRIMARY KEY (doctor_id,attention_time_slot_id,date),
 CONSTRAINT fk_ds_doctor FOREIGN KEY (doctor_id) REFERENCES doctor (id),
 CONSTRAINT fk_ds_attention FOREIGN KEY (attention_time_slot_id) REFERENCES attention_time_slot (id)
)

Ten en cuenta que los tipos de las claves foraneas deben ser del mismo tipo y mismo nombre.

1
  • la pregunta esta incompleta pues no muestra la estructura delas tablas restantes sería ideal esperar a que el OP agregue lo faltante necesario
    – user75901
    el 20 may. 2018 a las 4:10

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.