-
Notifications
You must be signed in to change notification settings - Fork 2
/
sample-db-script.sql
380 lines (370 loc) · 24.3 KB
/
sample-db-script.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
USE [master]
GO
/****** Object: Database [HEDIYE] Script Date: 18.08.2020 11:12:09 ******/
CREATE DATABASE [HEDIYE]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'SolidOrnek', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\HEDIYE.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'SolidOrnek_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\HEDIYE_log.ldf' , SIZE = 4224KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [HEDIYE] SET COMPATIBILITY_LEVEL = 110
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [HEDIYE].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [HEDIYE] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [HEDIYE] SET ANSI_NULLS OFF
GO
ALTER DATABASE [HEDIYE] SET ANSI_PADDING OFF
GO
ALTER DATABASE [HEDIYE] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [HEDIYE] SET ARITHABORT OFF
GO
ALTER DATABASE [HEDIYE] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [HEDIYE] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [HEDIYE] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [HEDIYE] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [HEDIYE] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [HEDIYE] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [HEDIYE] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [HEDIYE] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [HEDIYE] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [HEDIYE] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [HEDIYE] SET DISABLE_BROKER
GO
ALTER DATABASE [HEDIYE] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [HEDIYE] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [HEDIYE] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [HEDIYE] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [HEDIYE] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [HEDIYE] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [HEDIYE] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [HEDIYE] SET RECOVERY FULL
GO
ALTER DATABASE [HEDIYE] SET MULTI_USER
GO
ALTER DATABASE [HEDIYE] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [HEDIYE] SET DB_CHAINING OFF
GO
ALTER DATABASE [HEDIYE] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF )
GO
ALTER DATABASE [HEDIYE] SET TARGET_RECOVERY_TIME = 0 SECONDS
GO
EXEC sys.sp_db_vardecimal_storage_format N'HEDIYE', N'ON'
GO
USE [HEDIYE]
GO
/****** Object: Table [dbo].[Category] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Category](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ParentCategoryId] [int] NOT NULL,
[Name] [nvarchar](100) NOT NULL,
[Summary] [nvarchar](200) NULL,
[Type] [varchar](50) NOT NULL,
[IsActive] [bit] NULL,
CONSTRAINT [PK_Category] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Contact] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contact](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](200) NOT NULL,
[Email] [varchar](200) NULL,
[Phone] [varchar](100) NULL,
[Subject] [varchar](200) NULL,
[Message] [text] NOT NULL,
[CreateDate] [datetime] NOT NULL,
CONSTRAINT [PK_Contact] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Menu] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Menu](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ParentMenuId] [int] NOT NULL,
[Name] [nvarchar](100) NOT NULL,
[Href] [nvarchar](200) NULL,
[OrderNo] [int] NULL,
[Type] [varchar](50) NOT NULL,
CONSTRAINT [PK_Menu] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Newsletter] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Newsletter](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Email] [nvarchar](100) NOT NULL,
[CreateDate] [datetime] NOT NULL,
[IsActive] [bit] NOT NULL,
CONSTRAINT [PK_Newsletter] 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].[Param] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Param](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](100) NOT NULL,
[Description] [varchar](1000) NULL,
[IsActive] [bit] NOT NULL,
CONSTRAINT [PK_Param] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Post] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Post](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Title] [nvarchar](255) NOT NULL,
[Summary] [varchar](1000) NULL,
[FullContent] [text] NULL,
[UserId] [int] NOT NULL,
[CreateDate] [datetime] NOT NULL,
[Type] [varchar](50) NOT NULL,
[IsActive] [bit] NOT NULL,
[ImagePath] [varchar](100) NULL,
[ReadCount] [int] NOT NULL,
[LikeCount] [int] NOT NULL,
[UnLikeCount] [int] NOT NULL,
[MetaTitle] [nvarchar](200) NULL,
[MetaKeyword] [nvarchar](200) NULL,
[MetaDescription] [nvarchar](300) NULL,
CONSTRAINT [PK_POST] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[PostCategory] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PostCategory](
[Id] [int] IDENTITY(1,1) NOT NULL,
[PostId] [int] NOT NULL,
[CategoryId] [int] NOT NULL,
CONSTRAINT [PK_PostCategory] 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].[PostComment] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[PostComment](
[Id] [int] IDENTITY(1,1) NOT NULL,
[PostId] [int] NOT NULL,
[Email] [varchar](100) NOT NULL,
[Name] [varchar](100) NOT NULL,
[Web] [varchar](100) NULL,
[Comment] [text] NOT NULL,
[IsActive] [bit] NOT NULL,
[CreateDate] [datetime] NOT NULL,
CONSTRAINT [PK_PostComment] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[PostDetail] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PostDetail](
[Id] [int] IDENTITY(1,1) NOT NULL,
[PostId] [int] NOT NULL,
[ReadCount] [int] NOT NULL,
[LikeCount] [int] NULL,
[UnLikeCount] [int] NULL,
[MetaTitle] [nvarchar](100) NULL,
[MetaKeyword] [nvarchar](100) NULL,
[MetaDescription] [nvarchar](200) NULL,
CONSTRAINT [PK_PostDetail] 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].[User] Script Date: 18.08.2020 11:12:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[User](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](50) NOT NULL,
[Password] [nvarchar](50) NOT NULL,
[FullName] [nvarchar](200) NOT NULL,
[Description] [text] NULL,
[Email] [varchar](100) NOT NULL,
[Web] [varchar](100) NULL,
[Phone] [varchar](50) NULL,
[Address] [varchar](1000) NULL,
[CityCode] [int] NULL,
[CountyCode] [int] NULL,
[MapsUrl] [varchar](500) NULL,
[ImageUrl] [varchar](100) NULL,
[Type] [varchar](50) NOT NULL,
[IsActive] [bit] NOT NULL,
CONSTRAINT [PK_User] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_Type] DEFAULT ('category') FOR [Type]
GO
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
ALTER TABLE [dbo].[Contact] ADD CONSTRAINT [DF_Contact_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
GO
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_Type] DEFAULT ('main') FOR [Type]
GO
ALTER TABLE [dbo].[Newsletter] ADD CONSTRAINT [DF_Newsletter_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
GO
ALTER TABLE [dbo].[Newsletter] ADD CONSTRAINT [DF_Newsletter_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_POST_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_Post_Type] DEFAULT ('post') FOR [Type]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_Post_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_Post_ReadCount] DEFAULT ((0)) FOR [ReadCount]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_Post_LikeCount] DEFAULT ((0)) FOR [LikeCount]
GO
ALTER TABLE [dbo].[Post] ADD CONSTRAINT [DF_Post_UnLikeCount] DEFAULT ((0)) FOR [UnLikeCount]
GO
ALTER TABLE [dbo].[PostComment] ADD CONSTRAINT [DF_PostComment_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
ALTER TABLE [dbo].[PostComment] ADD CONSTRAINT [DF_Comment_CreateDate] DEFAULT (getdate()) FOR [CreateDate]
GO
ALTER TABLE [dbo].[PostDetail] ADD CONSTRAINT [DF_PostDetail_ReadCount] DEFAULT ((0)) FOR [ReadCount]
GO
ALTER TABLE [dbo].[PostDetail] ADD CONSTRAINT [DF_PostDetail_LikeCount] DEFAULT ((0)) FOR [LikeCount]
GO
ALTER TABLE [dbo].[PostDetail] ADD CONSTRAINT [DF_PostDetail_UnLikeCount] DEFAULT ((0)) FOR [UnLikeCount]
GO
ALTER TABLE [dbo].[User] ADD CONSTRAINT [DF_User_Type] DEFAULT ('author') FOR [Type]
GO
ALTER TABLE [dbo].[User] ADD CONSTRAINT [DF_User_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
ALTER TABLE [dbo].[Post] WITH CHECK ADD CONSTRAINT [FK_Post_User] FOREIGN KEY([UserId])
REFERENCES [dbo].[User] ([Id])
GO
ALTER TABLE [dbo].[Post] CHECK CONSTRAINT [FK_Post_User]
GO
ALTER TABLE [dbo].[PostCategory] WITH CHECK ADD CONSTRAINT [FK_PostCategory_Category] FOREIGN KEY([CategoryId])
REFERENCES [dbo].[Category] ([Id])
GO
ALTER TABLE [dbo].[PostCategory] CHECK CONSTRAINT [FK_PostCategory_Category]
GO
ALTER TABLE [dbo].[PostCategory] WITH CHECK ADD CONSTRAINT [FK_PostCategory_Post] FOREIGN KEY([PostId])
REFERENCES [dbo].[Post] ([Id])
GO
ALTER TABLE [dbo].[PostCategory] CHECK CONSTRAINT [FK_PostCategory_Post]
GO
ALTER TABLE [dbo].[PostComment] WITH CHECK ADD CONSTRAINT [FK_PostComment_Post] FOREIGN KEY([PostId])
REFERENCES [dbo].[Post] ([Id])
GO
ALTER TABLE [dbo].[PostComment] CHECK CONSTRAINT [FK_PostComment_Post]
GO
ALTER TABLE [dbo].[PostDetail] WITH CHECK ADD CONSTRAINT [FK_PostDetail_Post] FOREIGN KEY([PostId])
REFERENCES [dbo].[Post] ([Id])
GO
ALTER TABLE [dbo].[PostDetail] CHECK CONSTRAINT [FK_PostDetail_Post]
GO
USE [master]
GO
ALTER DATABASE [HEDIYE] SET READ_WRITE
GO