/****** Object: Table [dbo].[AttachedProduct] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[AttachedProduct]( [MainProductID] [int] NOT NULL, [AttachedProductID] [int] NOT NULL, CONSTRAINT [PK_AttachedProduct] PRIMARY KEY CLUSTERED ( [MainProductID] ASC, [AttachedProductID] 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 /****** Object: Table [dbo].[Client] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Client]( [ID] [int] IDENTITY(1,1) NOT NULL, [FirstName] [nvarchar](50) NOT NULL, [LastName] [nvarchar](50) NOT NULL, [Patronymic] [nvarchar](50) NULL, [Birthday] [date] NULL, [RegistrationDate] [datetime] NOT NULL, [Email] [nvarchar](255) NULL, [Phone] [nvarchar](20) NOT NULL, [GenderCode] [nchar](1) NOT NULL, [PhotoPath] [nvarchar](1000) NULL, CONSTRAINT [PK_Client] 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] GO /****** Object: Table [dbo].[ClientService] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ClientService]( [ID] [int] IDENTITY(1,1) NOT NULL, [ClientID] [int] NOT NULL, [ServiceID] [int] NOT NULL, [StartTime] [datetime] NOT NULL, [Comment] [nvarchar](max) NULL, CONSTRAINT [PK_ClientService] 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 /****** Object: Table [dbo].[DocumentByService] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[DocumentByService]( [ID] [int] IDENTITY(1,1) NOT NULL, [ClientServiceID] [int] NOT NULL, [DocumentPath] [nvarchar](1000) NOT NULL, CONSTRAINT [PK_DocumentByService] 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] GO /****** Object: Table [dbo].[Gender] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Gender]( [Code] [nchar](1) NOT NULL, [Name] [nvarchar](10) NULL, CONSTRAINT [PK_Gender] 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 /****** Object: Table [dbo].[Manufacturer] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Manufacturer]( [ID] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](100) NOT NULL, [StartDate] [date] NULL, CONSTRAINT [PK_Manufacturer] 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] GO /****** Object: Table [dbo].[Product] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Product]( [ID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](100) NOT NULL, [Cost] [money] NOT NULL, [Description] [nvarchar](max) NULL, [MainImagePath] [nvarchar](1000) NULL, [IsActive] [bit] NOT NULL, [ManufacturerID] [int] NULL, CONSTRAINT [PK_Product] 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 /****** Object: Table [dbo].[ProductPhoto] Script Date: 12/2/2019 10:23:09 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ProductPhoto]( [ID] [int] IDENTITY(1,1) NOT NULL, [ProductID] [int] NOT NULL, [PhotoPath] [nvarchar](1000) NOT NULL, CONSTRAINT [PK_ProductPhoto] 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] GO /****** Object: Table [dbo].[ProductSale] Script Date: 12/2/2019 10:23:10 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ProductSale]( [ID] [int] IDENTITY(1,1) NOT NULL, [SaleDate] [datetime] NOT NULL, [ProductID] [int] NOT NULL, [Quantity] [int] NOT NULL, [ClientServiceID] [int] NULL, CONSTRAINT [PK_ProductSale] 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] GO /****** Object: Table [dbo].[Service] Script Date: 12/2/2019 10:23:10 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Service]( [ID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](100) NOT NULL, [Cost] [money] NOT NULL, [DurationInSeconds] [int] NOT NULL, [Description] [nvarchar](max) NULL, [Discount] [float] NULL, [MainImagePath] [nvarchar](1000) NULL, CONSTRAINT [PK_Service] 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 /****** Object: Table [dbo].[ServicePhoto] Script Date: 12/2/2019 10:23:10 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ServicePhoto]( [ID] [int] IDENTITY(1,1) NOT NULL, [ServiceID] [int] NOT NULL, [PhotoPath] [nvarchar](1000) NOT NULL, CONSTRAINT [PK_ServicePhoto] 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] GO /****** Object: Table [dbo].[Tag] Script Date: 12/2/2019 10:23:10 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Tag]( [ID] [int] IDENTITY(1,1) NOT NULL, [Title] [nvarchar](30) NOT NULL, [Color] [nchar](6) NOT NULL, CONSTRAINT [PK_Tag] 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] GO /****** Object: Table [dbo].[TagOfClient] Script Date: 12/2/2019 10:23:10 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[TagOfClient]( [ClientID] [int] NOT NULL, [TagID] [int] NOT NULL, CONSTRAINT [PK_TagOfClient] PRIMARY KEY CLUSTERED ( [ClientID] ASC, [TagID] 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].[AttachedProduct] WITH CHECK ADD CONSTRAINT [FK_AttachedProduct_Product] FOREIGN KEY([MainProductID]) REFERENCES [dbo].[Product] ([ID]) GO ALTER TABLE [dbo].[AttachedProduct] CHECK CONSTRAINT [FK_AttachedProduct_Product] GO ALTER TABLE [dbo].[AttachedProduct] WITH CHECK ADD CONSTRAINT [FK_AttachedProduct_Product1] FOREIGN KEY([AttachedProductID]) REFERENCES [dbo].[Product] ([ID]) GO ALTER TABLE [dbo].[AttachedProduct] CHECK CONSTRAINT [FK_AttachedProduct_Product1] GO ALTER TABLE [dbo].[Client] WITH CHECK ADD CONSTRAINT [FK_Client_Gender] FOREIGN KEY([GenderCode]) REFERENCES [dbo].[Gender] ([Code]) GO ALTER TABLE [dbo].[Client] CHECK CONSTRAINT [FK_Client_Gender] GO ALTER TABLE [dbo].[ClientService] WITH CHECK ADD CONSTRAINT [FK_ClientService_Client] FOREIGN KEY([ClientID]) REFERENCES [dbo].[Client] ([ID]) GO ALTER TABLE [dbo].[ClientService] CHECK CONSTRAINT [FK_ClientService_Client] GO ALTER TABLE [dbo].[ClientService] WITH CHECK ADD CONSTRAINT [FK_ClientService_Service] FOREIGN KEY([ServiceID]) REFERENCES [dbo].[Service] ([ID]) GO ALTER TABLE [dbo].[ClientService] CHECK CONSTRAINT [FK_ClientService_Service] GO ALTER TABLE [dbo].[DocumentByService] WITH CHECK ADD CONSTRAINT [FK_DocumentByService_ClientService] FOREIGN KEY([ClientServiceID]) REFERENCES [dbo].[ClientService] ([ID]) GO ALTER TABLE [dbo].[DocumentByService] CHECK CONSTRAINT [FK_DocumentByService_ClientService] GO ALTER TABLE [dbo].[Product] WITH CHECK ADD CONSTRAINT [FK_Product_Manufacturer] FOREIGN KEY([ManufacturerID]) REFERENCES [dbo].[Manufacturer] ([ID]) GO ALTER TABLE [dbo].[Product] CHECK CONSTRAINT [FK_Product_Manufacturer] GO ALTER TABLE [dbo].[ProductPhoto] WITH CHECK ADD CONSTRAINT [FK_ProductPhoto_Product] FOREIGN KEY([ProductID]) REFERENCES [dbo].[Product] ([ID]) GO ALTER TABLE [dbo].[ProductPhoto] CHECK CONSTRAINT [FK_ProductPhoto_Product] GO ALTER TABLE [dbo].[ProductSale] WITH CHECK ADD CONSTRAINT [FK_ProductSale_ClientService] FOREIGN KEY([ClientServiceID]) REFERENCES [dbo].[ClientService] ([ID]) GO ALTER TABLE [dbo].[ProductSale] CHECK CONSTRAINT [FK_ProductSale_ClientService] GO ALTER TABLE [dbo].[ProductSale] WITH CHECK ADD CONSTRAINT [FK_ProductSale_Product] FOREIGN KEY([ProductID]) REFERENCES [dbo].[Product] ([ID]) GO ALTER TABLE [dbo].[ProductSale] CHECK CONSTRAINT [FK_ProductSale_Product] GO ALTER TABLE [dbo].[ServicePhoto] WITH CHECK ADD CONSTRAINT [FK_ServicePhoto_Service] FOREIGN KEY([ServiceID]) REFERENCES [dbo].[Service] ([ID]) GO ALTER TABLE [dbo].[ServicePhoto] CHECK CONSTRAINT [FK_ServicePhoto_Service] GO ALTER TABLE [dbo].[TagOfClient] WITH CHECK ADD CONSTRAINT [FK_TagOfClient_Client] FOREIGN KEY([ClientID]) REFERENCES [dbo].[Client] ([ID]) GO ALTER TABLE [dbo].[TagOfClient] CHECK CONSTRAINT [FK_TagOfClient_Client] GO ALTER TABLE [dbo].[TagOfClient] WITH CHECK ADD CONSTRAINT [FK_TagOfClient_Tag] FOREIGN KEY([TagID]) REFERENCES [dbo].[Tag] ([ID]) GO ALTER TABLE [dbo].[TagOfClient] CHECK CONSTRAINT [FK_TagOfClient_Tag] GO