SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Country]( [Code] [nchar](2) NOT NULL, [Name] [nvarchar](100) NOT NULL, CONSTRAINT [PK_Country] PRIMARY KEY CLUSTERED ( [Code] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Hotel]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT NULL, [CountOfStars] [int] NOT NULL, [CountryCode] [nchar](2) NOT NULL, [Description] [nvarchar](max) NULL, CONSTRAINT [PK_Hotel] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[HotelComment]( [Id] [int] IDENTITY(1,1) NOT NULL, [HotelId] [int] NOT NULL, [Text] [nvarchar](max) NOT NULL, [Author] [nvarchar](100) NOT NULL, [CreationDate] [datetime] NOT NULL, CONSTRAINT [PK_HotelComment] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[HotelImage]( [Id] [int] IDENTITY(1,1) NOT NULL, [HotelId] [int] NOT NULL, [ImageSource] [varbinary](max) NOT NULL, CONSTRAINT [PK_HotelImage] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[HotelOfTour]( [HotelId] [int] NOT NULL, [TourId] [int] NOT NULL, CONSTRAINT [PK_HotelOfTour] PRIMARY KEY CLUSTERED ( [HotelId] ASC, [TourId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Tour]( [Id] [int] IDENTITY(1,1) NOT NULL, [TicketCount] [int] NOT NULL, [Name] [nvarchar](100) NOT NULL, [Description] [nvarchar](max) NULL, [ImagePreview] [varbinary](max) NULL, [Price] [money] NOT NULL, [IsActual] [bit] NOT NULL, CONSTRAINT [PK_Tour] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Type]( [Id] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT NULL, [Description] [nvarchar](max) NULL, CONSTRAINT [PK_Type] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[TypeOfTour]( [TourId] [int] NOT NULL, [TypeId] [int] NOT NULL, CONSTRAINT [PK_TypeOfTour] PRIMARY KEY CLUSTERED ( [TourId] ASC, [TypeId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO ALTER TABLE [dbo].[Hotel] WITH CHECK ADD CONSTRAINT [FK_Hotel_Country] FOREIGN KEY([CountryCode]) REFERENCES [dbo].[Country] ([Code]) GO ALTER TABLE [dbo].[Hotel] CHECK CONSTRAINT [FK_Hotel_Country] GO ALTER TABLE [dbo].[HotelComment] WITH CHECK ADD CONSTRAINT [FK_HotelComment_Hotel] FOREIGN KEY([HotelId]) REFERENCES [dbo].[Hotel] ([Id]) GO ALTER TABLE [dbo].[HotelComment] CHECK CONSTRAINT [FK_HotelComment_Hotel] GO ALTER TABLE [dbo].[HotelImage] WITH CHECK ADD CONSTRAINT [FK_HotelImage_Hotel] FOREIGN KEY([HotelId]) REFERENCES [dbo].[Hotel] ([Id]) GO ALTER TABLE [dbo].[HotelImage] CHECK CONSTRAINT [FK_HotelImage_Hotel] GO ALTER TABLE [dbo].[HotelOfTour] WITH CHECK ADD CONSTRAINT [FK_HotelOfTour_Hotel] FOREIGN KEY([HotelId]) REFERENCES [dbo].[Hotel] ([Id]) GO ALTER TABLE [dbo].[HotelOfTour] CHECK CONSTRAINT [FK_HotelOfTour_Hotel] GO ALTER TABLE [dbo].[HotelOfTour] WITH CHECK ADD CONSTRAINT [FK_HotelOfTour_Tour] FOREIGN KEY([TourId]) REFERENCES [dbo].[Tour] ([Id]) GO ALTER TABLE [dbo].[HotelOfTour] CHECK CONSTRAINT [FK_HotelOfTour_Tour] GO ALTER TABLE [dbo].[TypeOfTour] WITH CHECK ADD CONSTRAINT [FK_TypeOfTour_Tour] FOREIGN KEY([TourId]) REFERENCES [dbo].[Tour] ([Id]) GO ALTER TABLE [dbo].[TypeOfTour] CHECK CONSTRAINT [FK_TypeOfTour_Tour] GO ALTER TABLE [dbo].[TypeOfTour] WITH CHECK ADD CONSTRAINT [FK_TypeOfTour_Type] FOREIGN KEY([TypeId]) REFERENCES [dbo].[Type] ([Id]) GO ALTER TABLE [dbo].[TypeOfTour] CHECK CONSTRAINT [FK_TypeOfTour_Type] GO