-
Notifications
You must be signed in to change notification settings - Fork 6
/
SCRIPT_FILE.sql
252 lines (252 loc) · 17.3 KB
/
SCRIPT_FILE.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
USE [master]
GO
/****** Object: Database [HMS] Script Date: 30/12/2021 8:36:46 pm ******/
CREATE DATABASE [HMS]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'HMS', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\HMS.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'HMS_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\HMS_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
WITH CATALOG_COLLATION = DATABASE_DEFAULT
GO
ALTER DATABASE [HMS] SET COMPATIBILITY_LEVEL = 150
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [HMS].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [HMS] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [HMS] SET ANSI_NULLS OFF
GO
ALTER DATABASE [HMS] SET ANSI_PADDING OFF
GO
ALTER DATABASE [HMS] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [HMS] SET ARITHABORT OFF
GO
ALTER DATABASE [HMS] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [HMS] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [HMS] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [HMS] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [HMS] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [HMS] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [HMS] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [HMS] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [HMS] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [HMS] SET DISABLE_BROKER
GO
ALTER DATABASE [HMS] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [HMS] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [HMS] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [HMS] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [HMS] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [HMS] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [HMS] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [HMS] SET RECOVERY FULL
GO
ALTER DATABASE [HMS] SET MULTI_USER
GO
ALTER DATABASE [HMS] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [HMS] SET DB_CHAINING OFF
GO
ALTER DATABASE [HMS] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [HMS] SET TARGET_RECOVERY_TIME = 60 SECONDS
GO
ALTER DATABASE [HMS] SET DELAYED_DURABILITY = DISABLED
GO
ALTER DATABASE [HMS] SET ACCELERATED_DATABASE_RECOVERY = OFF
GO
EXEC sys.sp_db_vardecimal_storage_format N'HMS', N'ON'
GO
ALTER DATABASE [HMS] SET QUERY_STORE = OFF
GO
USE [HMS]
GO
/****** Object: Table [dbo].[Department] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Department](
[ID] [int] IDENTITY(1,1) NOT NULL,
[DepartmentName] [nvarchar](50) NULL,
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].[DoctorRoles] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DoctorRoles](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Rolename] [nvarchar](50) NULL,
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].[DOCTORS] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DOCTORS](
[ID] [int] IDENTITY(1,1) NOT NULL,
[DOC_ID] AS ('DID'+right('-000000'+CONVERT([varchar](7),[ID]),(7))) PERSISTED,
[DOC_NAME] [varchar](50) NOT NULL,
[DOC_DEP_ID] [int] NOT NULL,
[DOC_TEL] [varchar](15) NOT NULL,
[DOC_EMAIL] [varchar](255) NOT NULL,
[DOC_PASS] [nvarchar](50) NOT NULL,
[DOC_GENDER] [varchar](7) NOT NULL,
[DOC_ADDRESS] [varchar](100) NOT NULL,
[DOC_Role_ID] [int] NOT NULL,
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],
UNIQUE NONCLUSTERED
(
[DOC_TEL] 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],
UNIQUE NONCLUSTERED
(
[DOC_EMAIL] 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: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EMPLOYEE](
[ID] [int] IDENTITY(1,1) NOT NULL,
[EMP_ID] AS ('EID'+right('-000000'+CONVERT([varchar](10),[ID]),(10))) PERSISTED,
[EMP_NAME] [varchar](50) NOT NULL,
[EMP_GENDER] [varchar](7) NOT NULL,
[EMP_PASS] [nvarchar](50) NOT NULL,
[DepartmentID] [int] NOT NULL,
[EMP_TEL] [varchar](15) NOT NULL,
[EMP_EMAIL] [varchar](255) NOT NULL,
[EMP_ADDRESS] [varchar](100) NOT NULL,
[RoleID] [int] NOT NULL,
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],
UNIQUE NONCLUSTERED
(
[EMP_EMAIL] 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],
UNIQUE NONCLUSTERED
(
[EMP_TEL] 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].[EmployeeRoles] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeeRoles](
[ID] [int] IDENTITY(1,1) NOT NULL,
[RoleName] [nvarchar](50) NULL,
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].[PATIENTS] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PATIENTS](
[ID] [int] IDENTITY(1,1) NOT NULL,
[PAT_ID] AS ('PID'+right('-000000'+CONVERT([varchar](7),[ID]),(7))) PERSISTED,
[PAT_NAME] [varchar](50) NOT NULL,
[PAT_TEL] [varchar](15) NOT NULL,
[PAT_EMAIL] [nvarchar](255) NOT NULL,
[PAT_GENDER] [varchar](7) NOT NULL,
[PAT_ADDRESS] [varchar](100) NOT NULL,
[Createdby] [int] NULL,
[PAT_DATE] [date] NOT NULL,
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],
UNIQUE NONCLUSTERED
(
[PAT_EMAIL] 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],
UNIQUE NONCLUSTERED
(
[PAT_TEL] 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].[ROOM] Script Date: 30/12/2021 8:36:47 pm ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ROOM](
[ID] [int] IDENTITY(1,1) NOT NULL,
[ROOM_NO] [varchar](10) NOT NULL,
[FLOOR_NO] [varchar](1) NOT NULL,
[ROOM_STATUS] [varchar](10) NOT NULL,
[ROOM_TYPE] [varchar](10) NOT NULL,
[PRICE_PER_DAY] [int] NOT NULL,
UNIQUE NONCLUSTERED
(
[ROOM_NO] 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
ALTER TABLE [dbo].[DOCTORS] WITH CHECK ADD FOREIGN KEY([DOC_DEP_ID])
REFERENCES [dbo].[Department] ([ID])
GO
ALTER TABLE [dbo].[DOCTORS] WITH CHECK ADD FOREIGN KEY([DOC_Role_ID])
REFERENCES [dbo].[DoctorRoles] ([ID])
GO
ALTER TABLE [dbo].[EMPLOYEE] WITH CHECK ADD FOREIGN KEY([DepartmentID])
REFERENCES [dbo].[Department] ([ID])
GO
ALTER TABLE [dbo].[EMPLOYEE] WITH CHECK ADD FOREIGN KEY([RoleID])
REFERENCES [dbo].[EmployeeRoles] ([ID])
GO
ALTER TABLE [dbo].[PATIENTS] WITH CHECK ADD FOREIGN KEY([Createdby])
REFERENCES [dbo].[EMPLOYEE] ([ID])
GO
USE [master]
GO
ALTER DATABASE [HMS] SET READ_WRITE
GO