Guest User

Untitled

a guest
Jan 21st, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. create table patient_room
  2. (
  3. pr_id int NOT NULL PRIMARY KEY auto_increment,
  4. patient_id int NOT NULL,
  5. room_id int NOT NULL,
  6. )ENGINE = InnoDB;
  7.  
  8. create table patients
  9. (
  10. patient_id int primary key not null auto_increment,
  11. fname varchar(30),
  12. lname varchar(30),
  13. suffix enum('I','II','III','IV','JR','SR'),
  14. sex enum('M','F','U','T'),
  15. eye_color enum('BK','BR','BL','GY','GR','HZ','MN','DX','UN'),
  16. hair_color enum('BK','BR','BN','RD','WH','SN','BD','UN'),
  17. date_of_birth date not null,
  18. height int unsigned not null,
  19. weight int unsigned not null,
  20. admitted datetime not null
  21. ) Engine = InnoDB;
  22.  
  23. alter table patient_room add foreign key (patient_id) references patient(patient_id) on delete cascade on update cascade;
  24.  
  25. ERROR 1005 (HY000): Can't create table 'Mthomas.#sql-3dac_5f1' (errno: 150)
  26.  
  27. alter table patient_room add foreign key (room_id) references room(room_id) on delete cascade on update cascade;
  28.  
  29. alter table patient_room add foreign key (patient_id) references patient(patient_id) on delete cascade on update cascade;
  30.  
  31. alter table patient_room add foreign key (patient_id) references patients(patient_id) on delete cascade on update cascade;
  32. ^
Add Comment
Please, Sign In to add comment