SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

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

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