Advertisement
Mochinov

Untitled

Dec 17th, 2020
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 3.04 KB | None | 0 0
  1. CREATE TABLE `child_birdth`( `id_child_birdth` Int NOT NULL, `cesarean_section` Enum('') NOT NULL,  `start` Time NOT NULL,  `the_end` Time NOT NULL,`child` Int NOT NULL, `doctor` Int NOT NULL,  `mother_in_labor` Int NOT NULL,  `id_child` Int NOT NULL, `id_doctor` Int NOT NULL, `id_mother_in_labor` Int NOT NULL, `id_accomodation` Int NOT NULL, `id_ward` Int NOT NULL);
  2.  
  3. ALTER TABLE `child_birdth` ADD PRIMARY KEY (`id_child_birdth`,`id_child`,`id_doctor`,`id_mother_in_labor`,`id_accomodation`,`id_ward`);
  4.  
  5. ALTER TABLE `child_birdth` ADD UNIQUE `id_child_birdth` (`id_child_birdth`);
  6.  
  7. CREATE TABLE `child`( `id_child` Int NOT NULL, `gender` Char(200) NOT NULL,`date_of_birth` Datetime NOT NULL,  `weight` Int NOT NULL, `growth` Int NOT NULL);
  8.  
  9. ALTER TABLE `child` ADD PRIMARY KEY (`id_child`);
  10.  
  11. ALTER TABLE `child` ADD UNIQUE `id_child` (`id_child`);
  12.  
  13. CREATE TABLE `doctor`(`id_doctor` Int NOT NULL, `name` Char(50) NOT NULL,`surname` Char(50) NOT NULL, `patronymic` Char(50) NOT NULL,`date_of_birth` Datetime NOT NULL,`employment_date` Datetime NOT NULL,`salary` Int NOT NULL);
  14.  
  15. ALTER TABLE `doctor` ADD PRIMARY KEY (`id_doctor`);
  16.  
  17. ALTER TABLE `doctor` ADD UNIQUE `id_doctor` (`id_doctor`);
  18.  
  19. CREATE TABLE `mother_in_labor`(`id_mother_in_labor` Int NOT NULL,`name` Char(50) NOT NULL,`surname` Char(50) NOT NULL,`patronymic` Char(50) NOT NULL,`date_of_birth` Datetime NOT NULL,`address` Varchar(200) NOT NULL,`phone` Char(13) NOT NULL,`blood_type` Enum('') NOT NULL,`ward` Int NOT NULL,`id_accomodation` Int NOT NULL,`id_ward` Int NOT NULL);
  20.  
  21. ALTER TABLE `mother_in_labor` ADD PRIMARY KEY (`id_mother_in_labor`,`id_accomodation`,`id_ward`);
  22.  
  23. ALTER TABLE `mother_in_labor` ADD UNIQUE `id_mother_in_labor` (`id_mother_in_labor`);
  24.  
  25. CREATE TABLE `ward`(`id_ward` Int NOT NULL,`number_of_seats` Int NOT NULL);
  26.  
  27. ALTER TABLE `ward` ADD PRIMARY KEY (`id_ward`);
  28.  
  29. ALTER TABLE `ward` ADD UNIQUE `id_ward` (`id_ward`);  
  30.  
  31. CREATE TABLE `accommodation`(`id_accomodation` Int NOT NULL,`mother_in_labor` Int NOT NULL);
  32.  
  33. ALTER TABLE `accommodation` ADD PRIMARY KEY (`id_accomodation`);
  34.  
  35. ALTER TABLE `accommodation` ADD UNIQUE `id_accomodation` (`id_accomodation`);
  36.  
  37.  
  38.  
  39.  
  40.  
  41. ALTER TABLE `child_birdth` ADD CONSTRAINT `Relationship1` FOREIGN KEY (`id_child`) REFERENCES `child` (`id_child`) ON DELETE RESTRICT ON UPDATE RESTRICT;
  42.  
  43. ALTER TABLE `child_birdth` ADD CONSTRAINT `Relationship2` FOREIGN KEY (`id_doctor`) REFERENCES `doctor` (`id_doctor`) ON DELETE RESTRICT ON UPDATE RESTRICT;
  44.  
  45. ALTER TABLE `child_birdth` ADD CONSTRAINT `Relationship3` FOREIGN KEY (`id_mother_in_labor`, `id_accomodation`, `id_ward`) REFERENCES `mother_in_labor` (`id_mother_in_labor`, `id_accomodation`, `id_ward`) ON DELETE RESTRICT ON UPDATE RESTRICT;
  46.  
  47. ALTER TABLE `mother_in_labor` ADD CONSTRAINT `Relationship4` FOREIGN KEY (`id_accomodation`) REFERENCES `accommodation` (`id_accomodation`) ON DELETE RESTRICT ON UPDATE RESTRICT;
  48.  
  49. ALTER TABLE `mother_in_labor` ADD CONSTRAINT `Relationship5` FOREIGN KEY (`id_ward`) REFERENCES `ward` (`id_ward`) ON DELETE RESTRICT ON UPDATE RESTRICT;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement