bd.sql 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. USE [Hospital]
  2. GO
  3. /****** Object: Table [dbo].[Departament] Script Date: 23.06.2022 12:06:03 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE TABLE [dbo].[Departament](
  9. [DepartamentId] [int] IDENTITY(1,1) NOT NULL,
  10. [TitleDepartament] [nvarchar](100) NULL,
  11. CONSTRAINT [PK_Departament] PRIMARY KEY CLUSTERED
  12. (
  13. [DepartamentId] ASC
  14. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  15. ) ON [PRIMARY]
  16. GO
  17. /****** Object: Table [dbo].[Doctor] Script Date: 23.06.2022 12:06:03 ******/
  18. SET ANSI_NULLS ON
  19. GO
  20. SET QUOTED_IDENTIFIER ON
  21. GO
  22. CREATE TABLE [dbo].[Doctor](
  23. [IdDoctor] [int] IDENTITY(1,1) NOT NULL,
  24. [LastName] [nvarchar](100) NULL,
  25. [FirstName] [nvarchar](100) NULL,
  26. [MiddleName] [nvarchar](100) NULL,
  27. [PostId] [int] NULL,
  28. [PhoneNumber] [varchar](20) NULL,
  29. [DepartamentId] [int] NULL,
  30. [CabinetNumber] [int] NULL,
  31. CONSTRAINT [PK_Doctor] PRIMARY KEY CLUSTERED
  32. (
  33. [IdDoctor] ASC
  34. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  35. ) ON [PRIMARY]
  36. GO
  37. /****** Object: Table [dbo].[ListNews] Script Date: 23.06.2022 12:06:03 ******/
  38. SET ANSI_NULLS ON
  39. GO
  40. SET QUOTED_IDENTIFIER ON
  41. GO
  42. CREATE TABLE [dbo].[ListNews](
  43. [IdNews] [int] IDENTITY(1,1) NOT NULL,
  44. [Title] [nvarchar](100) NULL,
  45. [DiscriptNews] [nvarchar](max) NULL,
  46. [DatePublication] [date] NULL,
  47. CONSTRAINT [PK_ListNews] PRIMARY KEY CLUSTERED
  48. (
  49. [IdNews] ASC
  50. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  51. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  52. GO
  53. /****** Object: Table [dbo].[Patient] Script Date: 23.06.2022 12:06:03 ******/
  54. SET ANSI_NULLS ON
  55. GO
  56. SET QUOTED_IDENTIFIER ON
  57. GO
  58. CREATE TABLE [dbo].[Patient](
  59. [IdPatient] [int] IDENTITY(1,1) NOT NULL,
  60. [LastName] [nvarchar](100) NULL,
  61. [FirstName] [nvarchar](100) NULL,
  62. [MiddleName] [nvarchar](100) NULL,
  63. [Gender] [nvarchar](10) NULL,
  64. [DateofBirth] [date] NULL,
  65. [Snils] [varchar](15) NULL,
  66. CONSTRAINT [PK_Patient] PRIMARY KEY CLUSTERED
  67. (
  68. [IdPatient] ASC
  69. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  70. ) ON [PRIMARY]
  71. GO
  72. /****** Object: Table [dbo].[Post] Script Date: 23.06.2022 12:06:03 ******/
  73. SET ANSI_NULLS ON
  74. GO
  75. SET QUOTED_IDENTIFIER ON
  76. GO
  77. CREATE TABLE [dbo].[Post](
  78. [PostId] [int] IDENTITY(1,1) NOT NULL,
  79. [TitlePost] [nvarchar](100) NULL,
  80. CONSTRAINT [PK_Post] PRIMARY KEY CLUSTERED
  81. (
  82. [PostId] ASC
  83. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  84. ) ON [PRIMARY]
  85. GO
  86. /****** Object: Table [dbo].[Status] Script Date: 23.06.2022 12:06:03 ******/
  87. SET ANSI_NULLS ON
  88. GO
  89. SET QUOTED_IDENTIFIER ON
  90. GO
  91. CREATE TABLE [dbo].[Status](
  92. [IdStatus] [int] IDENTITY(1,1) NOT NULL,
  93. [TitleStatus] [nvarchar](100) NULL,
  94. CONSTRAINT [PK_Status] PRIMARY KEY CLUSTERED
  95. (
  96. [IdStatus] ASC
  97. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  98. ) ON [PRIMARY]
  99. GO
  100. /****** Object: Table [dbo].[User] Script Date: 23.06.2022 12:06:03 ******/
  101. SET ANSI_NULLS ON
  102. GO
  103. SET QUOTED_IDENTIFIER ON
  104. GO
  105. CREATE TABLE [dbo].[User](
  106. [IdUser] [int] IDENTITY(1,1) NOT NULL,
  107. [LoginUser] [varchar](100) NULL,
  108. [PasswordUser] [varchar](100) NULL,
  109. [IdPatient] [int] NULL,
  110. [IdDoctor] [int] NULL,
  111. [IdStatus] [int] NULL,
  112. CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED
  113. (
  114. [IdUser] ASC
  115. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  116. ) ON [PRIMARY]
  117. GO
  118. SET IDENTITY_INSERT [dbo].[Departament] ON
  119. INSERT [dbo].[Departament] ([DepartamentId], [TitleDepartament]) VALUES (1, N'Терапевтический корпус')
  120. INSERT [dbo].[Departament] ([DepartamentId], [TitleDepartament]) VALUES (2, N'Санитарный пропускник (санпропускник)')
  121. INSERT [dbo].[Departament] ([DepartamentId], [TitleDepartament]) VALUES (3, N'Хирургический корпус')
  122. INSERT [dbo].[Departament] ([DepartamentId], [TitleDepartament]) VALUES (4, N'Травмпункт')
  123. INSERT [dbo].[Departament] ([DepartamentId], [TitleDepartament]) VALUES (5, N'Клиническое отделение')
  124. SET IDENTITY_INSERT [dbo].[Departament] OFF
  125. GO
  126. SET IDENTITY_INSERT [dbo].[Doctor] ON
  127. INSERT [dbo].[Doctor] ([IdDoctor], [LastName], [FirstName], [MiddleName], [PostId], [PhoneNumber], [DepartamentId], [CabinetNumber]) VALUES (1, N'Данил', N'Васильев', N'Незнаюкин', 1, N'88005553535', 4, 225)
  128. SET IDENTITY_INSERT [dbo].[Doctor] OFF
  129. GO
  130. SET IDENTITY_INSERT [dbo].[ListNews] ON
  131. INSERT [dbo].[ListNews] ([IdNews], [Title], [DiscriptNews], [DatePublication]) VALUES (1, N'Первая новость', N'Это тестовая новость для проверки работы', CAST(N'2022-06-22' AS Date))
  132. INSERT [dbo].[ListNews] ([IdNews], [Title], [DiscriptNews], [DatePublication]) VALUES (2, N'Втарая новость', N'Это тестовая новость для проверки работы', CAST(N'2022-06-22' AS Date))
  133. SET IDENTITY_INSERT [dbo].[ListNews] OFF
  134. GO
  135. SET IDENTITY_INSERT [dbo].[Patient] ON
  136. INSERT [dbo].[Patient] ([IdPatient], [LastName], [FirstName], [MiddleName], [Gender], [DateofBirth], [Snils]) VALUES (1, N'Иванов', N'Иван', N'Иванович', N'Муж', CAST(N'2003-12-02' AS Date), N'12312312312')
  137. INSERT [dbo].[Patient] ([IdPatient], [LastName], [FirstName], [MiddleName], [Gender], [DateofBirth], [Snils]) VALUES (2, N'qwe', N'qweq', N'qwe', N'Муж', CAST(N'2022-06-07' AS Date), N'12312312376')
  138. SET IDENTITY_INSERT [dbo].[Patient] OFF
  139. GO
  140. SET IDENTITY_INSERT [dbo].[Post] ON
  141. INSERT [dbo].[Post] ([PostId], [TitlePost]) VALUES (1, N'Врач')
  142. INSERT [dbo].[Post] ([PostId], [TitlePost]) VALUES (2, N'Мед-сестра')
  143. INSERT [dbo].[Post] ([PostId], [TitlePost]) VALUES (3, N'Глав-врач')
  144. SET IDENTITY_INSERT [dbo].[Post] OFF
  145. GO
  146. SET IDENTITY_INSERT [dbo].[Status] ON
  147. INSERT [dbo].[Status] ([IdStatus], [TitleStatus]) VALUES (1, N'Поциент')
  148. INSERT [dbo].[Status] ([IdStatus], [TitleStatus]) VALUES (2, N'Врач')
  149. SET IDENTITY_INSERT [dbo].[Status] OFF
  150. GO
  151. SET IDENTITY_INSERT [dbo].[User] ON
  152. INSERT [dbo].[User] ([IdUser], [LoginUser], [PasswordUser], [IdPatient], [IdDoctor], [IdStatus]) VALUES (1, N'qwe', N'qwe', 1, NULL, 1)
  153. INSERT [dbo].[User] ([IdUser], [LoginUser], [PasswordUser], [IdPatient], [IdDoctor], [IdStatus]) VALUES (2, N'12', N'12', NULL, 1, 2)
  154. INSERT [dbo].[User] ([IdUser], [LoginUser], [PasswordUser], [IdPatient], [IdDoctor], [IdStatus]) VALUES (3, N'asd', N'asd', 2, NULL, 1)
  155. SET IDENTITY_INSERT [dbo].[User] OFF
  156. GO
  157. ALTER TABLE [dbo].[Doctor] WITH CHECK ADD CONSTRAINT [FK_Doctor_Departament] FOREIGN KEY([DepartamentId])
  158. REFERENCES [dbo].[Departament] ([DepartamentId])
  159. GO
  160. ALTER TABLE [dbo].[Doctor] CHECK CONSTRAINT [FK_Doctor_Departament]
  161. GO
  162. ALTER TABLE [dbo].[Doctor] WITH CHECK ADD CONSTRAINT [FK_Doctor_Post] FOREIGN KEY([PostId])
  163. REFERENCES [dbo].[Post] ([PostId])
  164. GO
  165. ALTER TABLE [dbo].[Doctor] CHECK CONSTRAINT [FK_Doctor_Post]
  166. GO
  167. ALTER TABLE [dbo].[User] WITH CHECK ADD CONSTRAINT [FK_User_Doctor] FOREIGN KEY([IdDoctor])
  168. REFERENCES [dbo].[Doctor] ([IdDoctor])
  169. GO
  170. ALTER TABLE [dbo].[User] CHECK CONSTRAINT [FK_User_Doctor]
  171. GO
  172. ALTER TABLE [dbo].[User] WITH CHECK ADD CONSTRAINT [FK_User_Patient] FOREIGN KEY([IdPatient])
  173. REFERENCES [dbo].[Patient] ([IdPatient])
  174. GO
  175. ALTER TABLE [dbo].[User] CHECK CONSTRAINT [FK_User_Patient]
  176. GO
  177. ALTER TABLE [dbo].[User] WITH CHECK ADD CONSTRAINT [FK_User_Status] FOREIGN KEY([IdStatus])
  178. REFERENCES [dbo].[Status] ([IdStatus])
  179. GO
  180. ALTER TABLE [dbo].[User] CHECK CONSTRAINT [FK_User_Status]
  181. GO