Advertisement
fgdjfgdjgfdj

Untitled

Feb 23rd, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. GO
  2. CREATE TABLE [dbo].[Dishes](
  3. [Id] [int] NOT NULL,
  4. [Name] [varchar](50) NOT NULL,
  5. CONSTRAINT [PK_Dishes] PRIMARY KEY CLUSTERED
  6. (
  7. [Id] ASC
  8. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  9. ) ON [PRIMARY]
  10. GO
  11. /****** Object: Table [dbo].[Products] Script Date: 23.02.2022 15:10:46 ******/
  12. SET ANSI_NULLS ON
  13. GO
  14. SET QUOTED_IDENTIFIER ON
  15. GO
  16. CREATE TABLE [dbo].[Products](
  17. [Id] [int] NOT NULL,
  18. [Name] [varchar](50) NULL,
  19. CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED
  20. (
  21. [Id] ASC
  22. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  23. ) ON [PRIMARY]
  24. GO
  25. /****** Object: Table [dbo].[Structure] Script Date: 23.02.2022 15:10:46 ******/
  26. SET ANSI_NULLS ON
  27. GO
  28. SET QUOTED_IDENTIFIER ON
  29. GO
  30. CREATE TABLE [dbo].[Structure](
  31. [DishId] [int] NOT NULL,
  32. [ProdId] [int] NOT NULL,
  33. [Quantity] [int] NOT NULL,
  34. CONSTRAINT [PK_Structure] PRIMARY KEY CLUSTERED
  35. (
  36. [DishId] ASC,
  37. [ProdId] ASC
  38. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  39. ) ON [PRIMARY]
  40. GO
  41. INSERT [dbo].[Dishes] ([Id], [Name]) VALUES (1, N'Potato and Meat')
  42. INSERT [dbo].[Dishes] ([Id], [Name]) VALUES (2, N'Tea')
  43. GO
  44. INSERT [dbo].[Products] ([Id], [Name]) VALUES (1, N'Meat')
  45. INSERT [dbo].[Products] ([Id], [Name]) VALUES (2, N'Potato')
  46. INSERT [dbo].[Products] ([Id], [Name]) VALUES (3, N'Water')
  47. INSERT [dbo].[Products] ([Id], [Name]) VALUES (4, N'Tea')
  48. INSERT [dbo].[Products] ([Id], [Name]) VALUES (5, N'Sugar')
  49. GO
  50. INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (1, 1, 100)
  51. INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (1, 2, 150)
  52. INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 3, 10)
  53. INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 4, 150)
  54. INSERT [dbo].[Structure] ([DishId], [ProdId], [Quantity]) VALUES (2, 5, 10)
  55. GO
  56. ALTER TABLE [dbo].[Structure] WITH CHECK ADD CONSTRAINT [FK_Structure_Dishes] FOREIGN KEY([DishId])
  57. REFERENCES [dbo].[Dishes] ([Id])
  58. GO
  59. ALTER TABLE [dbo].[Structure] CHECK CONSTRAINT [FK_Structure_Dishes]
  60. GO
  61. ALTER TABLE [dbo].[Structure] WITH CHECK ADD CONSTRAINT [FK_Structure_Products] FOREIGN KEY([ProdId])
  62. REFERENCES [dbo].[Products] ([Id])
  63. GO
  64. ALTER TABLE [dbo].[Structure] CHECK CONSTRAINT [FK_Structure_Products]
  65. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement