SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HTETKIKDOKUMAN]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[HTETKIKDOKUMAN](
	[HTETKIKDOKUMANID] [int] NOT NULL,
	[HTETKIKKARTID] [int] NOT NULL,
	[TARIH] [datetime] NOT NULL,
	[ACIKLAMA] [nvarchar](200) NULL,
	[ADRES] [nvarchar](200) NOT NULL,
	[DOSYA] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_HTETKIKDOKUMAN] PRIMARY KEY CLUSTERED 
(
	[HTETKIKDOKUMANID] 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_HTETKIKDOKUMAN_HTETKIKKART]') AND parent_object_id = OBJECT_ID(N'[dbo].[HTETKIKDOKUMAN]'))
ALTER TABLE [dbo].[HTETKIKDOKUMAN]  WITH CHECK ADD  CONSTRAINT [FK_HTETKIKDOKUMAN_HTETKIKKART] FOREIGN KEY([HTETKIKKARTID])
REFERENCES [dbo].[HTETKIKKART] ([HTETKIKKARTID])
GO

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