Advertisement
selebry

fsdfds

Nov 17th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. -- MySQL Script generated by MySQL Workbench
  2. -- Fri Nov 17 14:00:26 2023
  3. -- Model: New Model Version: 1.0
  4. -- MySQL Workbench Forward Engineering
  5.  
  6. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  7. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  8. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
  9.  
  10. -- -----------------------------------------------------
  11. -- Schema mydb
  12. -- -----------------------------------------------------
  13. -- -----------------------------------------------------
  14. -- Schema taxi_handler
  15. -- -----------------------------------------------------
  16.  
  17. -- -----------------------------------------------------
  18. -- Schema taxi_handler
  19. -- -----------------------------------------------------
  20. CREATE SCHEMA IF NOT EXISTS `taxi_handler` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
  21. USE `taxi_handler` ;
  22.  
  23. -- -----------------------------------------------------
  24. -- Table `taxi_handler`.`drivers`
  25. -- -----------------------------------------------------
  26. CREATE TABLE IF NOT EXISTS `taxi_handler`.`drivers` (
  27. `id_driver` INT NOT NULL AUTO_INCREMENT,
  28. `name_first` VARCHAR(25) NOT NULL,
  29. `name_second` VARCHAR(25) NOT NULL,
  30. `phone` VARCHAR(20) NOT NULL,
  31. `email` VARCHAR(50) NOT NULL,
  32. `number_license` VARCHAR(15) NOT NULL,
  33. PRIMARY KEY (`id_driver`))
  34. ENGINE = InnoDB
  35. DEFAULT CHARACTER SET = utf8mb4
  36. COLLATE = utf8mb4_0900_ai_ci;
  37.  
  38.  
  39. -- -----------------------------------------------------
  40. -- Table `taxi_handler`.`fares`
  41. -- -----------------------------------------------------
  42. CREATE TABLE IF NOT EXISTS `taxi_handler`.`fares` (
  43. `id_fare` INT NOT NULL AUTO_INCREMENT,
  44. `title` VARCHAR(45) NOT NULL,
  45. `description` VARCHAR(45) NOT NULL,
  46. PRIMARY KEY (`id_fare`))
  47. ENGINE = InnoDB
  48. DEFAULT CHARACTER SET = utf8mb4
  49. COLLATE = utf8mb4_0900_ai_ci;
  50.  
  51.  
  52. -- -----------------------------------------------------
  53. -- Table `taxi_handler`.`cars`
  54. -- -----------------------------------------------------
  55. CREATE TABLE IF NOT EXISTS `taxi_handler`.`cars` (
  56. `id_car` INT NOT NULL AUTO_INCREMENT,
  57. `brand` VARCHAR(100) NOT NULL,
  58. `model` VARCHAR(100) NOT NULL,
  59. `year_release` YEAR NOT NULL,
  60. `color` CHAR(7) NOT NULL,
  61. `number_plate` VARCHAR(10) CHARACTER SET 'utf8mb3' NOT NULL,
  62. `id_driver` INT NULL DEFAULT NULL,
  63. `id_fare` INT NOT NULL,
  64. PRIMARY KEY (`id_car`),
  65. INDEX `id_driver` (`id_driver` ASC) VISIBLE,
  66. INDEX `id_fare` (`id_fare` ASC) VISIBLE,
  67. CONSTRAINT `cars_ibfk_1`
  68. FOREIGN KEY (`id_driver`)
  69. REFERENCES `taxi_handler`.`drivers` (`id_driver`),
  70. CONSTRAINT `cars_ibfk_2`
  71. FOREIGN KEY (`id_fare`)
  72. REFERENCES `taxi_handler`.`fares` (`id_fare`))
  73. ENGINE = InnoDB
  74. DEFAULT CHARACTER SET = utf8mb4
  75. COLLATE = utf8mb4_0900_ai_ci;
  76.  
  77.  
  78. -- -----------------------------------------------------
  79. -- Table `taxi_handler`.`clients`
  80. -- -----------------------------------------------------
  81. CREATE TABLE IF NOT EXISTS `taxi_handler`.`clients` (
  82. `id_client` INT NOT NULL AUTO_INCREMENT,
  83. `name_first` VARCHAR(25) NOT NULL,
  84. `name_second` VARCHAR(25) NOT NULL,
  85. `phone` VARCHAR(255) NOT NULL,
  86. `email` VARCHAR(255) NOT NULL,
  87. PRIMARY KEY (`id_client`))
  88. ENGINE = InnoDB
  89. DEFAULT CHARACTER SET = utf8mb4
  90. COLLATE = utf8mb4_0900_ai_ci;
  91.  
  92.  
  93. -- -----------------------------------------------------
  94. -- Table `taxi_handler`.`orders`
  95. -- -----------------------------------------------------
  96. CREATE TABLE IF NOT EXISTS `taxi_handler`.`orders` (
  97. `id_order` INT NOT NULL AUTO_INCREMENT,
  98. `id_client` INT NOT NULL,
  99. `id_driver` INT NOT NULL,
  100. `address_source` VARCHAR(255) NOT NULL,
  101. `address_target` VARCHAR(255) NOT NULL,
  102. `id_fare` INT NOT NULL,
  103. PRIMARY KEY (`id_order`),
  104. INDEX `id_client` (`id_client` ASC) VISIBLE,
  105. INDEX `id_driver` (`id_driver` ASC) VISIBLE,
  106. INDEX `id_fare` (`id_fare` ASC) VISIBLE,
  107. CONSTRAINT `orders_ibfk_1`
  108. FOREIGN KEY (`id_client`)
  109. REFERENCES `taxi_handler`.`clients` (`id_client`),
  110. CONSTRAINT `orders_ibfk_2`
  111. FOREIGN KEY (`id_driver`)
  112. REFERENCES `taxi_handler`.`drivers` (`id_driver`),
  113. CONSTRAINT `orders_ibfk_3`
  114. FOREIGN KEY (`id_fare`)
  115. REFERENCES `taxi_handler`.`fares` (`id_fare`))
  116. ENGINE = InnoDB
  117. DEFAULT CHARACTER SET = utf8mb4
  118. COLLATE = utf8mb4_0900_ai_ci;
  119.  
  120.  
  121. -- -----------------------------------------------------
  122. -- Table `taxi_handler`.`order details`
  123. -- -----------------------------------------------------
  124. CREATE TABLE IF NOT EXISTS `taxi_handler`.`order details` (
  125. `id_order_detail` INT NOT NULL AUTO_INCREMENT,
  126. `date_order` DATETIME NOT NULL,
  127. `payment_type` ENUM('cash', 'card') NOT NULL,
  128. `cost` DECIMAL(10,2) NOT NULL,
  129. `status` ENUM('delivery', 'progress', 'done') NOT NULL,
  130. PRIMARY KEY (`id_order_detail`),
  131. CONSTRAINT `order details_ibfk_1`
  132. FOREIGN KEY (`id_order_detail`)
  133. REFERENCES `taxi_handler`.`orders` (`id_order`))
  134. ENGINE = InnoDB
  135. DEFAULT CHARACTER SET = utf8mb4
  136. COLLATE = utf8mb4_0900_ai_ci;
  137.  
  138.  
  139. -- -----------------------------------------------------
  140. -- Table `taxi_handler`.`rates`
  141. -- -----------------------------------------------------
  142. CREATE TABLE IF NOT EXISTS `taxi_handler`.`rates` (
  143. `id_rate` INT NOT NULL AUTO_INCREMENT,
  144. `id_order` INT NOT NULL,
  145. `id_driver` INT NOT NULL,
  146. `id_client` INT NOT NULL,
  147. `rate_client` INT NOT NULL,
  148. `rate_driver` INT NOT NULL,
  149. PRIMARY KEY (`id_rate`),
  150. INDEX `id_order` (`id_order` ASC) VISIBLE,
  151. INDEX `id_driver` (`id_driver` ASC) VISIBLE,
  152. INDEX `id_client` (`id_client` ASC) VISIBLE,
  153. CONSTRAINT `rates_ibfk_1`
  154. FOREIGN KEY (`id_order`)
  155. REFERENCES `taxi_handler`.`orders` (`id_order`),
  156. CONSTRAINT `rates_ibfk_2`
  157. FOREIGN KEY (`id_driver`)
  158. REFERENCES `taxi_handler`.`drivers` (`id_driver`),
  159. CONSTRAINT `rates_ibfk_3`
  160. FOREIGN KEY (`id_client`)
  161. REFERENCES `taxi_handler`.`clients` (`id_client`))
  162. ENGINE = InnoDB
  163. DEFAULT CHARACTER SET = utf8mb4
  164. COLLATE = utf8mb4_0900_ai_ci;
  165.  
  166.  
  167. SET SQL_MODE=@OLD_SQL_MODE;
  168. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  169. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  170.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement