my.sql 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. SET FOREIGN_KEY_CHECKS = 0;
  2. -- ----------------------------------------------------------------------------
  3. -- Table dbo.Country
  4. -- ----------------------------------------------------------------------------
  5. CREATE TABLE IF NOT EXISTS `Country` (
  6. `Code` CHAR(2) CHARACTER SET 'utf8mb4' NOT NULL,
  7. `Name` VARCHAR(100) CHARACTER SET 'utf8mb4' NOT NULL,
  8. PRIMARY KEY (`Code`));
  9. -- ----------------------------------------------------------------------------
  10. -- Table dbo.Hotel
  11. -- ----------------------------------------------------------------------------
  12. CREATE TABLE IF NOT EXISTS `Hotel` (
  13. `Id` INT NOT NULL AUTO_INCREMENT,
  14. `Name` VARCHAR(100) CHARACTER SET 'utf8mb4' NOT NULL,
  15. `CountOfStars` INT NOT NULL,
  16. `CountryCode` CHAR(2) CHARACTER SET 'utf8mb4' NOT NULL,
  17. `Description` LONGTEXT CHARACTER SET 'utf8mb4' NULL,
  18. PRIMARY KEY (`Id`),
  19. CONSTRAINT `FK_Hotel_Country`
  20. FOREIGN KEY (`CountryCode`)
  21. REFERENCES `Country` (`Code`)
  22. ON DELETE NO ACTION
  23. ON UPDATE NO ACTION);
  24. -- ----------------------------------------------------------------------------
  25. -- Table dbo.HotelComment
  26. -- ----------------------------------------------------------------------------
  27. CREATE TABLE IF NOT EXISTS `HotelComment` (
  28. `Id` INT NOT NULL AUTO_INCREMENT,
  29. `HotelId` INT NOT NULL,
  30. `Text` LONGTEXT CHARACTER SET 'utf8mb4' NOT NULL,
  31. `Author` VARCHAR(100) CHARACTER SET 'utf8mb4' NOT NULL,
  32. `CreationDate` DATETIME(6) NOT NULL,
  33. PRIMARY KEY (`Id`),
  34. CONSTRAINT `FK_HotelComment_Hotel`
  35. FOREIGN KEY (`HotelId`)
  36. REFERENCES `Hotel` (`Id`)
  37. ON DELETE NO ACTION
  38. ON UPDATE NO ACTION);
  39. -- ----------------------------------------------------------------------------
  40. -- Table dbo.HotelImage
  41. -- ----------------------------------------------------------------------------
  42. CREATE TABLE IF NOT EXISTS `HotelImage` (
  43. `Id` INT NOT NULL AUTO_INCREMENT,
  44. `HotelId` INT NOT NULL,
  45. `ImageSource` LONGBLOB NOT NULL,
  46. PRIMARY KEY (`Id`),
  47. CONSTRAINT `FK_HotelImage_Hotel`
  48. FOREIGN KEY (`HotelId`)
  49. REFERENCES `Hotel` (`Id`)
  50. ON DELETE NO ACTION
  51. ON UPDATE NO ACTION);
  52. -- ----------------------------------------------------------------------------
  53. -- Table dbo.HotelOfTour
  54. -- ----------------------------------------------------------------------------
  55. CREATE TABLE IF NOT EXISTS `HotelOfTour` (
  56. `HotelId` INT NOT NULL,
  57. `TourId` INT NOT NULL,
  58. PRIMARY KEY (`HotelId`, `TourId`),
  59. CONSTRAINT `FK_HotelOfTour_Hotel`
  60. FOREIGN KEY (`HotelId`)
  61. REFERENCES `Hotel` (`Id`)
  62. ON DELETE NO ACTION
  63. ON UPDATE NO ACTION,
  64. CONSTRAINT `FK_HotelOfTour_Tour`
  65. FOREIGN KEY (`TourId`)
  66. REFERENCES `Tour` (`Id`)
  67. ON DELETE NO ACTION
  68. ON UPDATE NO ACTION);
  69. -- ----------------------------------------------------------------------------
  70. -- Table dbo.Tour
  71. -- ----------------------------------------------------------------------------
  72. CREATE TABLE IF NOT EXISTS `Tour` (
  73. `Id` INT NOT NULL AUTO_INCREMENT,
  74. `TicketCount` INT NOT NULL,
  75. `Name` VARCHAR(100) CHARACTER SET 'utf8mb4' NOT NULL,
  76. `Description` LONGTEXT CHARACTER SET 'utf8mb4' NULL,
  77. `ImagePreview` LONGBLOB NULL,
  78. `Price` DECIMAL(19,4) NOT NULL,
  79. `IsActual` TINYINT(1) NOT NULL,
  80. PRIMARY KEY (`Id`));
  81. -- ----------------------------------------------------------------------------
  82. -- Table dbo.Type
  83. -- ----------------------------------------------------------------------------
  84. CREATE TABLE IF NOT EXISTS `Type` (
  85. `Id` INT NOT NULL AUTO_INCREMENT,
  86. `Name` VARCHAR(100) CHARACTER SET 'utf8mb4' NOT NULL,
  87. `Description` LONGTEXT CHARACTER SET 'utf8mb4' NULL,
  88. PRIMARY KEY (`Id`));
  89. -- ----------------------------------------------------------------------------
  90. -- Table dbo.TypeOfTour
  91. -- ----------------------------------------------------------------------------
  92. CREATE TABLE IF NOT EXISTS `TypeOfTour` (
  93. `TourId` INT NOT NULL,
  94. `TypeId` INT NOT NULL,
  95. PRIMARY KEY (`TourId`, `TypeId`),
  96. CONSTRAINT `FK_TypeOfTour_Tour`
  97. FOREIGN KEY (`TourId`)
  98. REFERENCES `Tour` (`Id`)
  99. ON DELETE NO ACTION
  100. ON UPDATE NO ACTION,
  101. CONSTRAINT `FK_TypeOfTour_Type`
  102. FOREIGN KEY (`TypeId`)
  103. REFERENCES `Type` (`Id`)
  104. ON DELETE NO ACTION
  105. ON UPDATE NO ACTION);
  106. SET FOREIGN_KEY_CHECKS = 1;