Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GO
- CREATE TABLE [dbo].[Dishes](
- [Id] [int] NOT NULL,
- [Name] [varchar](50) 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) ON [PRIMARY]
- ) ON [PRIMARY]
- GO
- /****** Object: Table [dbo].[Products] Script Date: 23.02.2022 15:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE TABLE [dbo].[Products](
- [Id] [int] NOT NULL,
- [Name] [varchar](50) NULL,
- CONSTRAINT [PK_Products] 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].[Structure] Script Date: 23.02.2022 15:10:46 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE TABLE [dbo].[Structure](
- [DishId] [int] NOT NULL,
- [ProdId] [int] NOT NULL,
- [Quantity] [int] NOT NULL,
- CONSTRAINT [PK_Structure] PRIMARY KEY CLUSTERED
- (
- [DishId] ASC,
- [ProdId] 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
- INSERT [dbo].[Dishes] ([Id], [Name]) VALUES (1, N'Potato and Meat')
- INSERT [dbo].[Dishes] ([Id], [Name]) VALUES (2, N'Tea')
- GO
- INSERT [dbo].[Products] ([Id], [Name]) VALUES (1, N'Meat')
- INSERT [dbo].[Products] ([Id], [Name]) VALUES (2, N'Potato')
- INSERT [dbo].[Products] ([Id], [Name]) VALUES (3, N'Water')
- INSERT [dbo].[Products] ([Id], [Name]) VALUES (4, N'Tea')
- INSERT [dbo].[Products] ([Id], [Name]) VALUES (5, N'Sugar')
- GO
- INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (1, 1, 100)
- INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (1, 2, 150)
- INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 3, 10)
- INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 4, 150)
- INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 5, 10)
- GO
- ALTER TABLE [dbo].[Structure] WITH CHECK ADD CONSTRAINT [FK_Structure_Dishes] FOREIGN KEY([DishId])
- REFERENCES [dbo].[Dishes] ([Id])
- GO
- ALTER TABLE [dbo].[Structure] CHECK CONSTRAINT [FK_Structure_Dishes]
- GO
- ALTER TABLE [dbo].[Structure] WITH CHECK ADD CONSTRAINT [FK_Structure_Products] FOREIGN KEY([ProdId])
- REFERENCES [dbo].[Products] ([Id])
- GO
- ALTER TABLE [dbo].[Structure] CHECK CONSTRAINT [FK_Structure_Products]
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement