Guest User

Untitled

a guest
May 25th, 2021
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.07 KB | None | 0 0
  1. #------------------------------------------------------------
  2. # Script MySQL.
  3. #------------------------------------------------------------
  4.  
  5.  
  6. #------------------------------------------------------------
  7. # Table: transportation
  8. #------------------------------------------------------------
  9.  
  10. CREATE TABLE transportation(
  11. idtransport Int Auto_increment NOT NULL ,
  12. transporttype Varchar (20) NOT NULL
  13. ,CONSTRAINT transportation_PK PRIMARY KEY (idtransport)
  14. )ENGINE=InnoDB;
  15.  
  16.  
  17. #------------------------------------------------------------
  18. # Table: client
  19. #------------------------------------------------------------
  20.  
  21. CREATE TABLE client(
  22. idclient Int Auto_increment NOT NULL ,
  23. nameclient Varchar (90) NOT NULL ,
  24. surnameclient Varchar (90) NOT NULL ,
  25. emailclient Varchar (120) NOT NULL ,
  26. phonenumberclient1 Varchar (10) NOT NULL ,
  27. phonenumberclient2 Varchar (10) NOT NULL ,
  28. gender Varchar (1) NOT NULL ,
  29. birthdateclient Date NOT NULL
  30. ,CONSTRAINT client_PK PRIMARY KEY (idclient)
  31. )ENGINE=InnoDB;
  32.  
  33.  
  34. #------------------------------------------------------------
  35. # Table: employees
  36. #------------------------------------------------------------
  37.  
  38. CREATE TABLE employees(
  39. idemployees Int Auto_increment NOT NULL ,
  40. nameemployees Varchar (90) NOT NULL ,
  41. surnameemployees Varchar (90) NOT NULL ,
  42. emailemployees Varchar (120) NOT NULL ,
  43. phonenumberemployees1 Varchar (10) NOT NULL ,
  44. phonenumberemployees2 Varchar (10) NOT NULL ,
  45. hiringdate Date NOT NULL
  46. ,CONSTRAINT employees_PK PRIMARY KEY (idemployees)
  47. )ENGINE=InnoDB;
  48.  
  49.  
  50. #------------------------------------------------------------
  51. # Table: adress
  52. #------------------------------------------------------------
  53.  
  54. CREATE TABLE adress(
  55. idadress Int Auto_increment NOT NULL ,
  56. number Varchar (10) NOT NULL ,
  57. city Varchar (120) NOT NULL ,
  58. streetname Varchar (120) NOT NULL ,
  59. residencename Varchar (100) NOT NULL ,
  60. buildingname Varchar (100) NOT NULL ,
  61. floor Varchar (10) NOT NULL ,
  62. postalcode Varchar (5) NOT NULL ,
  63. idemployees Int NOT NULL ,
  64. idclientbilling Int NOT NULL ,
  65. idclientdelivery Int NOT NULL
  66. ,CONSTRAINT adress_PK PRIMARY KEY (idadress)
  67.  
  68. ,CONSTRAINT adress_employees_FK FOREIGN KEY (idemployees) REFERENCES employees(idemployees)
  69. ,CONSTRAINT adress_client0_FK FOREIGN KEY (idclientbilling) REFERENCES client(idclient)
  70. ,CONSTRAINT adress_client1_FK FOREIGN KEY (idclientdelivery) REFERENCES client(idclient)
  71. ,CONSTRAINT adress_employees_AK UNIQUE (idemployees)
  72. ,CONSTRAINT adress_client0_AK UNIQUE (idclientbilling)
  73. ,CONSTRAINT adress_client1_AK UNIQUE (idclientdelivery)
  74. )ENGINE=InnoDB;
  75.  
  76.  
  77. #------------------------------------------------------------
  78. # Table: othertraveler
  79. #------------------------------------------------------------
  80.  
  81. CREATE TABLE othertraveler(
  82. idtraveler Int Auto_increment NOT NULL ,
  83. birthdatetraveler Date NOT NULL ,
  84. nametraveler Varchar (90) NOT NULL ,
  85. surnametraveler Varchar (90) NOT NULL ,
  86. gendertraveler Varchar (1) NOT NULL ,
  87. idclient Int NOT NULL
  88. ,CONSTRAINT othertraveler_PK PRIMARY KEY (idtraveler)
  89.  
  90. ,CONSTRAINT othertraveler_client_FK FOREIGN KEY (idclient) REFERENCES client(idclient)
  91. )ENGINE=InnoDB;
  92.  
  93.  
  94. #------------------------------------------------------------
  95. # Table: paymentmethod
  96. #------------------------------------------------------------
  97.  
  98. CREATE TABLE paymentmethod(
  99. idmethod Int Auto_increment NOT NULL ,
  100. paymentmethod Varchar (20) NOT NULL
  101. ,CONSTRAINT paymentmethod_PK PRIMARY KEY (idmethod)
  102. )ENGINE=InnoDB;
  103.  
  104.  
  105. #------------------------------------------------------------
  106. # Table: city
  107. #------------------------------------------------------------
  108.  
  109. CREATE TABLE city(
  110. idcity Int Auto_increment NOT NULL ,
  111. city Varchar (120) NOT NULL
  112. ,CONSTRAINT city_PK PRIMARY KEY (idcity)
  113. )ENGINE=InnoDB;
  114.  
  115.  
  116. #------------------------------------------------------------
  117. # Table: cataloguecity
  118. #------------------------------------------------------------
  119.  
  120. CREATE TABLE cataloguecity(
  121. idcataloguecity Int Auto_increment NOT NULL ,
  122. expirationdate Date NOT NULL ,
  123. idcity Int NOT NULL
  124. ,CONSTRAINT cataloguecity_PK PRIMARY KEY (idcataloguecity)
  125.  
  126. ,CONSTRAINT cataloguecity_city_FK FOREIGN KEY (idcity) REFERENCES city(idcity)
  127. )ENGINE=InnoDB;
  128.  
  129.  
  130. #------------------------------------------------------------
  131. # Table: travel
  132. #------------------------------------------------------------
  133.  
  134. CREATE TABLE travel(
  135. idtravel Int Auto_increment NOT NULL ,
  136. departuredate Datetime NOT NULL ,
  137. arrivaldate Datetime NOT NULL ,
  138. idemployees Int NOT NULL ,
  139. idclient Int NOT NULL ,
  140. idcataloguecitydeparture Int NOT NULL ,
  141. idcataloguecityarrival Int NOT NULL
  142. ,CONSTRAINT travel_PK PRIMARY KEY (idtravel)
  143.  
  144. ,CONSTRAINT travel_employees_FK FOREIGN KEY (idemployees) REFERENCES employees(idemployees)
  145. ,CONSTRAINT travel_client0_FK FOREIGN KEY (idclient) REFERENCES client(idclient)
  146. ,CONSTRAINT travel_cataloguecity1_FK FOREIGN KEY (idcataloguecitydeparture) REFERENCES cataloguecity(idcataloguecity)
  147. ,CONSTRAINT travel_cataloguecity2_FK FOREIGN KEY (idcataloguecityarrival) REFERENCES cataloguecity(idcataloguecity)
  148. )ENGINE=InnoDB;
  149.  
  150. #------------------------------------------------------------
  151. # Table: payment
  152. #------------------------------------------------------------
  153.  
  154. CREATE TABLE payment(
  155. idpayment Int Auto_increment NOT NULL ,
  156. travelprice DECIMAL (15,3) NOT NULL ,
  157. paymentdate Date NOT NULL ,
  158. paymentamount DECIMAL (15,3) NOT NULL ,
  159. dateorder Date NOT NULL ,
  160. idtravel Int NOT NULL ,
  161. idmethod Int NOT NULL
  162. ,CONSTRAINT payment_PK PRIMARY KEY (idpayment)
  163.  
  164. ,CONSTRAINT payment_travel_FK FOREIGN KEY (idtravel) REFERENCES travel(idtravel)
  165. ,CONSTRAINT payment_paymentmethod0_FK FOREIGN KEY (idmethod) REFERENCES paymentmethod(idmethod)
  166. )ENGINE=InnoDB;
  167.  
  168.  
  169. #------------------------------------------------------------
  170. # Table: distance
  171. #------------------------------------------------------------
  172.  
  173. CREATE TABLE distance(
  174. iddistance Int Auto_increment NOT NULL ,
  175. distance Float NOT NULL ,
  176. idcitystart Int NOT NULL ,
  177. idcityend Int NOT NULL
  178. ,CONSTRAINT distance_PK PRIMARY KEY (iddistance)
  179.  
  180. ,CONSTRAINT distance_city_FK FOREIGN KEY (idcitystart) REFERENCES city(idcity)
  181. ,CONSTRAINT distance_city0_FK FOREIGN KEY (idcityend) REFERENCES city(idcity)
  182. )ENGINE=InnoDB;
  183.  
  184. #------------------------------------------------------------
  185. # Table: stage
  186. #------------------------------------------------------------
  187. CREATE TABLE stage(
  188. idstage Int Auto_increment NOT NULL ,
  189. idtravel Int NOT NULL ,
  190. idtransport Int NOT NULL ,
  191. idcataloguecitystartstage Int NOT NULL ,
  192. idcataloguecityendstage Int NOT NULL ,
  193. iddistance Int NOT NULL
  194. ,CONSTRAINT stage_PK PRIMARY KEY (idstage)
  195.  
  196. ,CONSTRAINT stage_travel_FK FOREIGN KEY (idtravel) REFERENCES travel(idtravel)
  197. ,CONSTRAINT stage_transportation0_FK FOREIGN KEY (idtransport) REFERENCES transportation(idtransport)
  198. ,CONSTRAINT stage_cataloguecity1_FK FOREIGN KEY (idcataloguecitystartstage) REFERENCES cataloguecity(idcataloguecity)
  199. ,CONSTRAINT stage_cataloguecity2_FK FOREIGN KEY (idcataloguecityendstage) REFERENCES cataloguecity(idcataloguecity)
  200. ,CONSTRAINT stage_distance3_FK FOREIGN KEY (iddistance) REFERENCES distance(iddistance)
  201. )ENGINE=InnoDB;
Advertisement
Add Comment
Please, Sign In to add comment