USE [KafeDB]
GO
/****** Object:  Table [dbo].[CookStatus]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CookStatus](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_CookStatus] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Dishes]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Dishes](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
	[Cost] [float] NOT NULL,
	[CookTime] [int] NOT NULL,
 CONSTRAINT [PK_Dishes] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Employee]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employee](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[LastName] [nvarchar](50) NOT NULL,
	[FirstName] [nvarchar](50) NOT NULL,
	[MiddleName] [nvarchar](50) NULL,
	[PositionID] [int] NOT NULL,
	[Login] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
	[StatusID] [int] NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Order]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Order](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[TableNumber] [int] NOT NULL,
	[ClientCount] [int] NOT NULL,
	[EmployeeID] [int] NOT NULL,
	[PayStatusID] [int] NOT NULL,
	[CookStatusID] [int] NOT NULL,
 CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[OrderDishes]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderDishes](
	[OrderID] [int] NOT NULL,
	[DishID] [int] NOT NULL,
 CONSTRAINT [PK_OrderDishes] PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC,
	[DishID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PayStatus]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PayStatus](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_PayStatus] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Position]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Position](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Position] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Shift]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Shift](
	[EmployeeID] [int] NOT NULL,
	[DateShift] [date] NOT NULL,
 CONSTRAINT [PK_Shift] PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC,
	[DateShift] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Status]    Script Date: 26.03.2022 17:38:19 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Status](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[CookStatus] ON 

INSERT [dbo].[CookStatus] ([ID], [Title]) VALUES (1, N'готовится')
INSERT [dbo].[CookStatus] ([ID], [Title]) VALUES (2, N'готов')
SET IDENTITY_INSERT [dbo].[CookStatus] OFF
GO
SET IDENTITY_INSERT [dbo].[Dishes] ON 

INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (2, N'опомо (opomo)', 487.37, 15)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (3, N'угюбо (ugyubo)', 339.58, 23)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (4, N'ямуде (yamude)', 1575.34, 47)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (5, N'гисек (gisek)', 4096.03, 12)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (6, N'эмоху (emohu)', 354.88, 52)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (7, N'эзего (ezego)', 4014.9, 52)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (8, N'матит (matit)', 1228.15, 34)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (9, N'абуно (abuno)', 2117.14, 15)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (10, N'югупа (yugupa)', 531.66, 53)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (11, N'амулу (amulu)', 903.58, 25)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (12, N'евако (evako)', 3791.92, 36)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (13, N'етомо (etomo)', 2020.12, 41)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (14, N'акоке (akoke)', 4281.29, 44)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (15, N'фанув (fanuv)', 438.02, 16)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (16, N'уселе (usele)', 1695.43, 52)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (17, N'етите (etite)', 4136.45, 41)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (18, N'исуду (isudu)', 887.18, 24)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (19, N'эриди (eridi)', 277.19, 29)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (20, N'анокэ (anoke)', 2411.02, 69)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (21, N'имала (imala)', 1984.64, 21)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (22, N'асуту (asutu)', 1311.71, 25)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (23, N'алище (alische)', 2894.32, 45)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (24, N'гелоп (gelop)', 1351.61, 20)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (25, N'упити (upiti)', 488.64, 48)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (26, N'ореси (oresi)', 2199.24, 20)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (27, N'югика (yugika)', 470.99, 14)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (28, N'ецюру (ecyuru)', 3980.43, 16)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (29, N'океба (okeba)', 612.75, 14)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (30, N'кюгэг (kyugeg)', 1396.56, 28)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (31, N'якиме (yakime)', 4157.87, 23)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (32, N'ухуди (uhudi)', 3321.17, 34)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (33, N'оруко (oruko)', 3272.78, 43)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (34, N'дагим (dagim)', 3925.89, 36)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (35, N'екуци (ekuci)', 1081.71, 39)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (36, N'енугу (enugu)', 383.54, 41)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (37, N'пирин (pirin)', 837.48, 21)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (38, N'омиби (omibi)', 3579.18, 12)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (39, N'адиве (adive)', 1828.48, 19)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (40, N'пюном (pyunom)', 3405.8, 62)
INSERT [dbo].[Dishes] ([ID], [Title], [Cost], [CookTime]) VALUES (41, N'улока (uloka)', 3470.7, 47)
SET IDENTITY_INSERT [dbo].[Dishes] OFF
GO
SET IDENTITY_INSERT [dbo].[Employee] ON 

INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (1, N'Гущин', N'Александр', N'Улебович', 3, N'Elley', N'wzFd4v', 1)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (2, N'Казаков', N'Гавриил', N'Геннадьевич', 2, N'Ollay', N'mEwRoQ', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (3, N'Брагин', N'Юлий', N'Фролович', 2, N'Blakery', N'tUwVqf', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (4, N'Назаров', N'Давид', N'Давидович', 1, N'Thokie', N'sv62Cu', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (5, N'Щукин', N'Борис', N'Геннадиевич', 2, N'Edex', N'lZmplZ', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (6, N'Гурьев', N'Ибрагил', N'Павлович', 3, N'Tomseph', N'nHl8DE', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (7, N'Панфилов', N'Рудольф', N'Лукьевич', 2, N'Louiecha', N'tDx6Is', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (8, N'Сафонов', N'Ираклий', N'Павлович', 2, N'Bobam', N'Yjqxd3', 1)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (9, N'Зуев', N'Семен', N'Богданович', 2, N'Ausni', N'wbicYa', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (10, N'Ковалёв', N'Игнат', N'Тарасович', 3, N'Blakeot', N'POtncQ', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (11, N'Потапов', N'Мечеслав', N'Васильевич', 3, N'Oscas', N'zvvDV9', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (12, N'Маслов', N'Арсений', N'Семёнович', 2, N'Lukethan', N'WUbbSS', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (13, N'Бирюкова', N'Анастасия', N'Германновна', 1, N'Bethala', N'SGRI28', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (14, N'Павлова', N'Анна', N'Антониновна', 2, N'Brooketha', N'YdL5dx', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (15, N'Ларионова', N'Джема', N'Богдановна', 3, N'Avasica', N'mF5pSy', 1)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (16, N'Якушева', N'Аэлита', N'Макаровна', 2, N'Mato', N'bS5D48', 2)
INSERT [dbo].[Employee] ([ID], [LastName], [FirstName], [MiddleName], [PositionID], [Login], [Password], [StatusID]) VALUES (17, N'Меркушева', N'Веста', N'Валентиновна', 2, N'Fretha', N'WyhoaP', 2)
SET IDENTITY_INSERT [dbo].[Employee] OFF
GO
SET IDENTITY_INSERT [dbo].[PayStatus] ON 

INSERT [dbo].[PayStatus] ([ID], [Title]) VALUES (1, N'принят')
INSERT [dbo].[PayStatus] ([ID], [Title]) VALUES (2, N'оплачен')
SET IDENTITY_INSERT [dbo].[PayStatus] OFF
GO
SET IDENTITY_INSERT [dbo].[Position] ON 

INSERT [dbo].[Position] ([ID], [Title]) VALUES (1, N'Администратор')
INSERT [dbo].[Position] ([ID], [Title]) VALUES (2, N'Официант')
INSERT [dbo].[Position] ([ID], [Title]) VALUES (3, N'Повар')
SET IDENTITY_INSERT [dbo].[Position] OFF
GO
SET IDENTITY_INSERT [dbo].[Status] ON 

INSERT [dbo].[Status] ([ID], [Title]) VALUES (1, N'Уволен')
INSERT [dbo].[Status] ([ID], [Title]) VALUES (2, N'Работает')
SET IDENTITY_INSERT [dbo].[Status] OFF
GO
ALTER TABLE [dbo].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Position] FOREIGN KEY([PositionID])
REFERENCES [dbo].[Position] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Position]
GO
ALTER TABLE [dbo].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Status] FOREIGN KEY([StatusID])
REFERENCES [dbo].[Status] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Status]
GO
ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_Order_CookStatus] FOREIGN KEY([CookStatusID])
REFERENCES [dbo].[CookStatus] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_Order_CookStatus]
GO
ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_Order_Employee] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employee] ([ID])
GO
ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_Order_Employee]
GO
ALTER TABLE [dbo].[Order]  WITH CHECK ADD  CONSTRAINT [FK_Order_PayStatus] FOREIGN KEY([PayStatusID])
REFERENCES [dbo].[PayStatus] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Order] CHECK CONSTRAINT [FK_Order_PayStatus]
GO
ALTER TABLE [dbo].[OrderDishes]  WITH CHECK ADD  CONSTRAINT [FK_OrderDishes_Dishes] FOREIGN KEY([DishID])
REFERENCES [dbo].[Dishes] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[OrderDishes] CHECK CONSTRAINT [FK_OrderDishes_Dishes]
GO
ALTER TABLE [dbo].[OrderDishes]  WITH CHECK ADD  CONSTRAINT [FK_OrderDishes_Order] FOREIGN KEY([OrderID])
REFERENCES [dbo].[Order] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[OrderDishes] CHECK CONSTRAINT [FK_OrderDishes_Order]
GO
ALTER TABLE [dbo].[Shift]  WITH CHECK ADD  CONSTRAINT [FK_Shift_Employee] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employee] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Shift] CHECK CONSTRAINT [FK_Shift_Employee]
GO
