peshopbs2

Untitled

Dec 8th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. CREATE TABLE `colonists` (
  2. `id` int(11) NOT NULL,
  3. `first_name` varchar(20) NOT NULL,
  4. `last_name` varchar(20) NOT NULL,
  5. `ucn` char(10) NOT NULL,
  6. `birth_date` date NOT NULL,
  7. PRIMARY KEY (`id`),
  8. UNIQUE KEY `ucn_UNIQUE` (`ucn`)
  9. );
  10.  
  11. CREATE TABLE `journeys` (
  12. `id` int(11) NOT NULL AUTO_INCREMENT,
  13. `journey_start` datetime NOT NULL,
  14. `journey_end` datetime NOT NULL,
  15. `purpose` enum('Medical','Technical','Educational','Military') DEFAULT NULL,
  16. `destination_spaceport_id` int(11) DEFAULT NULL,
  17. `spaceship_id` int(11) DEFAULT NULL,
  18. PRIMARY KEY (`id`),
  19. KEY `FK_SPACEPORTS_idx` (`destination_spaceport_id`),
  20. KEY `FK_SPACESHIPS_idx` (`spaceship_id`),
  21. CONSTRAINT `FK_SPACEPORTS` FOREIGN KEY (`destination_spaceport_id`) REFERENCES `spaceports` (`id`),
  22. CONSTRAINT `FK_SPACESHIPS` FOREIGN KEY (`spaceship_id`) REFERENCES `spaceships` (`id`)
  23. );
  24.  
  25. CREATE TABLE `planets` (
  26. `id` int(11) NOT NULL AUTO_INCREMENT,
  27. `name` varchar(30) NOT NULL,
  28. PRIMARY KEY (`id`)
  29. );
  30.  
  31. CREATE TABLE `spaceports` (
  32. `id` int(11) NOT NULL AUTO_INCREMENT,
  33. `name` varchar(50) NOT NULL,
  34. `planet_id` int(11) DEFAULT NULL,
  35. PRIMARY KEY (`id`),
  36. KEY `FK_PLANET_idx` (`planet_id`),
  37. CONSTRAINT `FK_PLANET` FOREIGN KEY (`planet_id`) REFERENCES `planets` (`id`)
  38. );
  39.  
  40. CREATE TABLE `spaceships` (
  41. `id` int(11) NOT NULL AUTO_INCREMENT,
  42. `name` varchar(50) NOT NULL,
  43. `manufacturer` varchar(30) NOT NULL,
  44. `light_speed_rate` int(11) DEFAULT '0',
  45. PRIMARY KEY (`id`)
  46. );
  47.  
  48.  
  49. CREATE TABLE `travel_cards` (
  50. `id` int(11) NOT NULL AUTO_INCREMENT,
  51. `card_number` char(10) NOT NULL,
  52. `job_during_journey` enum('Pilot','Engineer','Trooper','Cleaner','Cook') DEFAULT NULL,
  53. `colonist_id` int(11) DEFAULT NULL,
  54. `journey_id` int(11) DEFAULT NULL,
  55. PRIMARY KEY (`id`),
  56. UNIQUE KEY `card_number_UNIQUE` (`card_number`),
  57. KEY `FK_COLONISTS_idx` (`colonist_id`),
  58. KEY `FK_JOURNEY_ID_idx` (`journey_id`),
  59. CONSTRAINT `FK_COLONISTS` FOREIGN KEY (`colonist_id`) REFERENCES `colonists` (`id`),
  60. CONSTRAINT `FK_JOURNEY_ID` FOREIGN KEY (`journey_id`) REFERENCES `journeys` (`id`)
  61. );
Advertisement
Add Comment
Please, Sign In to add comment