ms.sql 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. SET ANSI_NULLS ON
  2. GO
  3. SET QUOTED_IDENTIFIER ON
  4. GO
  5. CREATE TABLE [dbo].[Country](
  6. [Code] [nchar](2) NOT NULL,
  7. [Name] [nvarchar](100) NOT NULL,
  8. CONSTRAINT [PK_Country] PRIMARY KEY CLUSTERED
  9. (
  10. [Code] ASC
  11. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  12. ) ON [PRIMARY]
  13. GO
  14. SET ANSI_NULLS ON
  15. GO
  16. SET QUOTED_IDENTIFIER ON
  17. GO
  18. CREATE TABLE [dbo].[Hotel](
  19. [Id] [int] IDENTITY(1,1) NOT NULL,
  20. [Name] [nvarchar](100) NOT NULL,
  21. [CountOfStars] [int] NOT NULL,
  22. [CountryCode] [nchar](2) NOT NULL,
  23. [Description] [nvarchar](max) NULL,
  24. CONSTRAINT [PK_Hotel] PRIMARY KEY CLUSTERED
  25. (
  26. [Id] ASC
  27. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  28. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  29. GO
  30. SET ANSI_NULLS ON
  31. GO
  32. SET QUOTED_IDENTIFIER ON
  33. GO
  34. CREATE TABLE [dbo].[HotelComment](
  35. [Id] [int] IDENTITY(1,1) NOT NULL,
  36. [HotelId] [int] NOT NULL,
  37. [Text] [nvarchar](max) NOT NULL,
  38. [Author] [nvarchar](100) NOT NULL,
  39. [CreationDate] [datetime] NOT NULL,
  40. CONSTRAINT [PK_HotelComment] PRIMARY KEY CLUSTERED
  41. (
  42. [Id] ASC
  43. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  44. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  45. GO
  46. SET ANSI_NULLS ON
  47. GO
  48. SET QUOTED_IDENTIFIER ON
  49. GO
  50. CREATE TABLE [dbo].[HotelImage](
  51. [Id] [int] IDENTITY(1,1) NOT NULL,
  52. [HotelId] [int] NOT NULL,
  53. [ImageSource] [varbinary](max) NOT NULL,
  54. CONSTRAINT [PK_HotelImage] PRIMARY KEY CLUSTERED
  55. (
  56. [Id] ASC
  57. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  58. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  59. GO
  60. SET ANSI_NULLS ON
  61. GO
  62. SET QUOTED_IDENTIFIER ON
  63. GO
  64. CREATE TABLE [dbo].[HotelOfTour](
  65. [HotelId] [int] NOT NULL,
  66. [TourId] [int] NOT NULL,
  67. CONSTRAINT [PK_HotelOfTour] PRIMARY KEY CLUSTERED
  68. (
  69. [HotelId] ASC,
  70. [TourId] ASC
  71. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  72. ) ON [PRIMARY]
  73. GO
  74. SET ANSI_NULLS ON
  75. GO
  76. SET QUOTED_IDENTIFIER ON
  77. GO
  78. CREATE TABLE [dbo].[Tour](
  79. [Id] [int] IDENTITY(1,1) NOT NULL,
  80. [TicketCount] [int] NOT NULL,
  81. [Name] [nvarchar](100) NOT NULL,
  82. [Description] [nvarchar](max) NULL,
  83. [ImagePreview] [varbinary](max) NULL,
  84. [Price] [money] NOT NULL,
  85. [IsActual] [bit] NOT NULL,
  86. CONSTRAINT [PK_Tour] PRIMARY KEY CLUSTERED
  87. (
  88. [Id] ASC
  89. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  90. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  91. GO
  92. SET ANSI_NULLS ON
  93. GO
  94. SET QUOTED_IDENTIFIER ON
  95. GO
  96. CREATE TABLE [dbo].[Type](
  97. [Id] [int] IDENTITY(1,1) NOT NULL,
  98. [Name] [nvarchar](100) NOT NULL,
  99. [Description] [nvarchar](max) NULL,
  100. CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED
  101. (
  102. [Id] ASC
  103. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  104. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  105. GO
  106. SET ANSI_NULLS ON
  107. GO
  108. SET QUOTED_IDENTIFIER ON
  109. GO
  110. CREATE TABLE [dbo].[TypeOfTour](
  111. [TourId] [int] NOT NULL,
  112. [TypeId] [int] NOT NULL,
  113. CONSTRAINT [PK_TypeOfTour] PRIMARY KEY CLUSTERED
  114. (
  115. [TourId] ASC,
  116. [TypeId] ASC
  117. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  118. ) ON [PRIMARY]
  119. GO
  120. ALTER TABLE [dbo].[Hotel] WITH CHECK ADD CONSTRAINT [FK_Hotel_Country] FOREIGN KEY([CountryCode])
  121. REFERENCES [dbo].[Country] ([Code])
  122. GO
  123. ALTER TABLE [dbo].[Hotel] CHECK CONSTRAINT [FK_Hotel_Country]
  124. GO
  125. ALTER TABLE [dbo].[HotelComment] WITH CHECK ADD CONSTRAINT [FK_HotelComment_Hotel] FOREIGN KEY([HotelId])
  126. REFERENCES [dbo].[Hotel] ([Id])
  127. GO
  128. ALTER TABLE [dbo].[HotelComment] CHECK CONSTRAINT [FK_HotelComment_Hotel]
  129. GO
  130. ALTER TABLE [dbo].[HotelImage] WITH CHECK ADD CONSTRAINT [FK_HotelImage_Hotel] FOREIGN KEY([HotelId])
  131. REFERENCES [dbo].[Hotel] ([Id])
  132. GO
  133. ALTER TABLE [dbo].[HotelImage] CHECK CONSTRAINT [FK_HotelImage_Hotel]
  134. GO
  135. ALTER TABLE [dbo].[HotelOfTour] WITH CHECK ADD CONSTRAINT [FK_HotelOfTour_Hotel] FOREIGN KEY([HotelId])
  136. REFERENCES [dbo].[Hotel] ([Id])
  137. GO
  138. ALTER TABLE [dbo].[HotelOfTour] CHECK CONSTRAINT [FK_HotelOfTour_Hotel]
  139. GO
  140. ALTER TABLE [dbo].[HotelOfTour] WITH CHECK ADD CONSTRAINT [FK_HotelOfTour_Tour] FOREIGN KEY([TourId])
  141. REFERENCES [dbo].[Tour] ([Id])
  142. GO
  143. ALTER TABLE [dbo].[HotelOfTour] CHECK CONSTRAINT [FK_HotelOfTour_Tour]
  144. GO
  145. ALTER TABLE [dbo].[TypeOfTour] WITH CHECK ADD CONSTRAINT [FK_TypeOfTour_Tour] FOREIGN KEY([TourId])
  146. REFERENCES [dbo].[Tour] ([Id])
  147. GO
  148. ALTER TABLE [dbo].[TypeOfTour] CHECK CONSTRAINT [FK_TypeOfTour_Tour]
  149. GO
  150. ALTER TABLE [dbo].[TypeOfTour] WITH CHECK ADD CONSTRAINT [FK_TypeOfTour_Type] FOREIGN KEY([TypeId])
  151. REFERENCES [dbo].[Type] ([Id])
  152. GO
  153. ALTER TABLE [dbo].[TypeOfTour] CHECK CONSTRAINT [FK_TypeOfTour_Type]
  154. GO