SET ANSI_NULLS ON
go

SET QUOTED_IDENTIFIER ON
go

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SIKAYETDOKUMAN]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SIKAYETDOKUMAN](
	[SIKAYETBELGEID] [int] NOT NULL,
	[SIKAYETID] [int] NOT NULL,
	[TARIH] [datetime] NOT NULL,
	[ACIKLAMA] [nvarchar](200) NULL,
	[ADRES] [nvarchar](200) NOT NULL,
	[DOSYA] [nvarchar](100) NOT NULL,
	[KYTKULLANICI] [nvarchar](25) NOT NULL,
	[KYTTARIH] [datetime] NOT NULL,
 CONSTRAINT [PK_SIKAYETDOKUMAN] PRIMARY KEY CLUSTERED 
(
	[SIKAYETBELGEID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
END
go

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SIKAYETDOKUMAN_SIKAYET]') AND parent_object_id = OBJECT_ID(N'[dbo].[SIKAYETDOKUMAN]'))
ALTER TABLE [dbo].[SIKAYETDOKUMAN] WITH CHECK ADD  CONSTRAINT [FK_SIKAYETDOKUMAN_SIKAYET] FOREIGN KEY([SIKAYETID])
REFERENCES [dbo].[SIKAYET] ([SIKAYETID])
go

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SIKAYETDOKUMAN_SIKAYET]') AND parent_object_id = OBJECT_ID(N'[dbo].[SIKAYETDOKUMAN]'))
ALTER TABLE [dbo].[SIKAYETDOKUMAN] CHECK CONSTRAINT [FK_SIKAYETDOKUMAN_SIKAYET]
go