USE [gr606_kusan]
GO
/****** Object:  Table [dbo].[Attractions]    Script Date: 02.06.2022 22:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Attractions](
	[IdAttractions] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[Price] [money] NOT NULL,
	[AgeLimit] [nvarchar](50) NULL,
	[IdUser] [int] NOT NULL,
 CONSTRAINT [PK_Attractions] PRIMARY KEY CLUSTERED 
(
	[IdAttractions] 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].[Card]    Script Date: 02.06.2022 22:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Card](
	[IdCard] [int] IDENTITY(1,1) NOT NULL,
	[NumberCard] [nvarchar](50) NOT NULL,
	[DataCard] [date] NOT NULL,
	[IdUser] [int] NOT NULL,
	[Balance] [money] NULL,
	[Bonus] [money] NULL,
 CONSTRAINT [PK_Card] PRIMARY KEY CLUSTERED 
(
	[IdCard] 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].[Stock]    Script Date: 02.06.2022 22:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Stock](
	[IdStock] [int] IDENTITY(1,1) NOT NULL,
	[Icon] [image] NULL,
	[Comment] [nvarchar](300) NULL,
	[DateStart] [date] NOT NULL,
	[DateEnd] [date] NOT NULL,
	[IdAttractions] [int] NOT NULL,
 CONSTRAINT [PK_Stock] PRIMARY KEY CLUSTERED 
(
	[IdStock] 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].[TypeAttractions]    Script Date: 02.06.2022 22:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TypeAttractions](
	[IdType] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](50) NOT NULL,
	[IdAttractions] [int] NOT NULL,
 CONSTRAINT [PK_TypeAttractions] PRIMARY KEY CLUSTERED 
(
	[IdType] 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].[User]    Script Date: 02.06.2022 22:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[User](
	[IdUser] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [nvarchar](50) NOT NULL,
	[LastName] [nvarchar](50) NOT NULL,
	[MiddleName] [nvarchar](50) NULL,
	[Login] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[IdUser] 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 IDENTITY_INSERT [dbo].[Attractions] ON 

INSERT [dbo].[Attractions] ([IdAttractions], [Name], [Price], [AgeLimit], [IdUser]) VALUES (2, N'Американские горки', 120.0000, N'5', 1)
INSERT [dbo].[Attractions] ([IdAttractions], [Name], [Price], [AgeLimit], [IdUser]) VALUES (3, N'вжух', 150.0000, N'11', 1)
SET IDENTITY_INSERT [dbo].[Attractions] OFF
GO
SET IDENTITY_INSERT [dbo].[Stock] ON 

INSERT [dbo].[Stock] ([IdStock], [Icon], [Comment], [DateStart], [DateEnd], [IdAttractions]) VALUES (4, NULL, N'оно робит', CAST(N'2022-05-20' AS Date), CAST(N'2022-06-20' AS Date), 2)
INSERT [dbo].[Stock] ([IdStock], [Icon], [Comment], [DateStart], [DateEnd], [IdAttractions]) VALUES (5, NULL, N'Ну знаете оно пока работает', CAST(N'2022-02-21' AS Date), CAST(N'2022-02-22' AS Date), 3)
SET IDENTITY_INSERT [dbo].[Stock] OFF
GO
SET IDENTITY_INSERT [dbo].[User] ON 

INSERT [dbo].[User] ([IdUser], [FirstName], [LastName], [MiddleName], [Login], [Password]) VALUES (1, N'fe', N'ef', N'fe', N'12', N'12')
INSERT [dbo].[User] ([IdUser], [FirstName], [LastName], [MiddleName], [Login], [Password]) VALUES (2, N'Владислав', N'Александров', N'Викторович', N'mail.ru', N'12')
SET IDENTITY_INSERT [dbo].[User] OFF
GO
ALTER TABLE [dbo].[Attractions]  WITH CHECK ADD  CONSTRAINT [FK_Attractions_User] FOREIGN KEY([IdUser])
REFERENCES [dbo].[User] ([IdUser])
GO
ALTER TABLE [dbo].[Attractions] CHECK CONSTRAINT [FK_Attractions_User]
GO
ALTER TABLE [dbo].[Card]  WITH CHECK ADD  CONSTRAINT [FK_Card_User] FOREIGN KEY([IdUser])
REFERENCES [dbo].[User] ([IdUser])
GO
ALTER TABLE [dbo].[Card] CHECK CONSTRAINT [FK_Card_User]
GO
ALTER TABLE [dbo].[Stock]  WITH CHECK ADD  CONSTRAINT [FK_Stock_Attractions] FOREIGN KEY([IdAttractions])
REFERENCES [dbo].[Attractions] ([IdAttractions])
GO
ALTER TABLE [dbo].[Stock] CHECK CONSTRAINT [FK_Stock_Attractions]
GO
ALTER TABLE [dbo].[TypeAttractions]  WITH CHECK ADD  CONSTRAINT [FK_TypeAttractions_Attractions] FOREIGN KEY([IdAttractions])
REFERENCES [dbo].[Attractions] ([IdAttractions])
GO
ALTER TABLE [dbo].[TypeAttractions] CHECK CONSTRAINT [FK_TypeAttractions_Attractions]
GO
