USE [ORKAGENELTANIM]

CREATE TABLE [dbo].[WEB_DUYURU](
	[DuyuruId] [int] IDENTITY(1,1) NOT NULL,
	[DuyuruAdi] [nchar](250) NULL,
	[Icerik] [nvarchar](max) NULL,
	[BaslangicTar] [datetime] NULL,
	[BitisTar] [datetime] NULL,
	[RolId] [int] NULL,
	[Aktif] [bit] NULL,
 CONSTRAINT [PK_WEB_DUYURU] PRIMARY KEY CLUSTERED 
(
	[DuyuruId] 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]

CREATE TABLE [dbo].[WEB_SURECROL](
	[SurecRolID] [int] IDENTITY(1,1) NOT NULL,
	[SurecID] [int] NULL,
	[RolId] [int] NULL,
	[OnayDurumu] [bit] NULL,
	[SurecTamam] [bit] NULL,
	[SurecAktif] [bit] NULL,
 CONSTRAINT [PK_WEB_SURECROL] PRIMARY KEY CLUSTERED 
(
	[SurecRolID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE [dbo].[WEB_SURECTANIM](
	[SurecId] [int] IDENTITY(1,1) NOT NULL,
	[SurecAdi] [nvarchar](250) NULL,
	[SurecTip] [int] NULL,
	[Aktif] [bit] NULL,
	[RolId] [int] NULL,
	[Konum] [int] NULL,
 CONSTRAINT [PK_SurecTanim] PRIMARY KEY CLUSTERED 
(
	[SurecId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


CREATE TABLE [dbo].[WEB_SURECTIP](
	[TipId] [int] IDENTITY(1,1) NOT NULL,
	[TipAdi] [nvarchar](250) NULL,
	[Aktif] [bit] NULL,
 CONSTRAINT [PK_WEB_SURECTIP] PRIMARY KEY CLUSTERED 
(
	[TipId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


SET IDENTITY_INSERT [dbo].[WEB_SURECTIP] ON 
INSERT [dbo].[WEB_SURECTIP] ([TipId], [TipAdi], [Aktif]) VALUES (1, N'İzin Süreci', 1)
INSERT [dbo].[WEB_SURECTIP] ([TipId], [TipAdi], [Aktif]) VALUES (2, N'Avans Süreci', 1)
SET IDENTITY_INSERT [dbo].[WEB_SURECTIP] OFF

ALTER TABLE [dbo].[WEB_DUYURU] ADD  CONSTRAINT [DF_WEB_DUYURU_Aktif]  DEFAULT ((1)) FOR [Aktif]
ALTER TABLE [dbo].[WEB_SURECROL] ADD  CONSTRAINT [DF_WEB_SURECROL_OnayDurumu]  DEFAULT ((0)) FOR [OnayDurumu]
ALTER TABLE [dbo].[WEB_SURECROL] ADD  CONSTRAINT [DF_WEB_SURECROL_SurecTamam]  DEFAULT ((0)) FOR [SurecTamam]
ALTER TABLE [dbo].[WEB_SURECTANIM] ADD  CONSTRAINT [DF_SurecTanim_Aktif]  DEFAULT ((1)) FOR [Aktif]
ALTER TABLE [dbo].[WEB_SURECTIP] ADD  CONSTRAINT [DF_WEB_SURECTIP_Aktif]  DEFAULT ((1)) FOR [Aktif]
ALTER TABLE [dbo].[WEB_DUYURU]  WITH CHECK ADD  CONSTRAINT [FK_WEB_DUYURU_WEB_ROL] FOREIGN KEY([RolId]) REFERENCES [dbo].[WEB_ROL] ([RolId])
ALTER TABLE [dbo].[WEB_DUYURU] CHECK CONSTRAINT [FK_WEB_DUYURU_WEB_ROL]
ALTER TABLE [dbo].[WEB_SURECROL]  WITH CHECK ADD  CONSTRAINT [FK_WEB_SURECROL_WEB_ROL] FOREIGN KEY([RolId]) REFERENCES [dbo].[WEB_ROL] ([RolId])
ALTER TABLE [dbo].[WEB_SURECROL] CHECK CONSTRAINT [FK_WEB_SURECROL_WEB_ROL]
ALTER TABLE [dbo].[WEB_SURECROL]  WITH CHECK ADD  CONSTRAINT [FK_WEB_SURECROL_WEB_SURECTANIM] FOREIGN KEY([SurecID]) REFERENCES [dbo].[WEB_SURECTANIM] ([SurecId])
ALTER TABLE [dbo].[WEB_SURECROL] CHECK CONSTRAINT [FK_WEB_SURECROL_WEB_SURECTANIM]
ALTER TABLE [dbo].[WEB_SURECTANIM]  WITH  CHECK ADD  CONSTRAINT [FK_WEB_SURECTANIM_WEB_SURECTIP] FOREIGN KEY([SurecTip]) REFERENCES [dbo].[WEB_SURECTIP] ([TipId])
ALTER TABLE [dbo].[WEB_SURECTANIM] CHECK CONSTRAINT [FK_WEB_SURECTANIM_WEB_SURECTIP]
ALTER TABLE [dbo].[WEB_SURECTANIM]  WITH CHECK ADD  CONSTRAINT [FK_WEB_SURECTANIM_WEB_ROL] FOREIGN KEY([RolId]) REFERENCES [dbo].[WEB_ROL] ([RolId])
ALTER TABLE [dbo].[WEB_SURECTANIM] CHECK CONSTRAINT [FK_WEB_SURECTANIM_WEB_ROL]
